namespace Tests.Pages.BuildCalculator;

public class TimingComponent
{
    private readonly Website _website;

    public TimingComponent(Website website)
    {
        _website = website;
    }

    public ILocator AttackTimeInput => FormNumberInput("Attack Time");
    public ILocator TravelTimeInput => FormNumberInput("Travel Time");

    private ILocator FormNumberInput(string label)
    {
        return _website.Locator(".formNumberContainer").Filter(new LocatorFilterOptions { HasText = label })
            .Locator("input[type='number']");
    }

    public async Task SetAttackTimeAsync(int value)
    {
        await AttackTimeInput.FillAsync(value.ToString());
        await AttackTimeInput.PressAsync("Enter");
    }

    public async Task SetTravelTimeAsync(int value)
    {
        await TravelTimeInput.FillAsync(value.ToString());
        await TravelTimeInput.PressAsync("Enter");
    }

    public async Task<string> GetAttackTimeAsync()
    {
        return await AttackTimeInput.InputValueAsync();
    }

    public async Task<string> GetTravelTimeAsync()
    {
        return await TravelTimeInput.InputValueAsync();
    }
}