package cz.moneta.test.dsl.util.task.monetaportal;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.monetaportal.HomePage;
import cz.moneta.test.dsl.monetaportal.MonetaPortal;
import cz.moneta.test.dsl.monetaportal.components.Web2Branch;
import cz.moneta.test.dsl.monetaportal.components.Web2Call;

import java.util.function.Function;

public class CommonTasks {

    private final Harness harness;

    public CommonTasks(Harness harness) {
        this.harness = harness;
    }

    public Function<MonetaPortal, HomePage> openHomePage() {
        return start -> start
                .openHomePage()
                .acceptCookies();
    }

    public Function<Web2Call, Web2Call> fillW2C(String mobilNumber) {
        return start -> start
                .clickW2CPhone()
                .fillW2CPhone(mobilNumber)
                .clickW2CSubmit()
                .checkW2CSuccessMessage()
                .clickW2CModalClose();
    }

    public Function<Web2Branch, Web2Branch> fillW2B(int visitDay, int visitTime, String clientFullName, String mobilNumber, String clientEmail) {
        return start -> start
                .clickVisitDay()
                .selectVisitDay(visitDay)
                .clickVisitTime()
                .selectVisitTime(visitTime)
                .clickW2BContinue()
                .fillW2BClientFullName(clientFullName)
                .fillW2BClientPhoneNumber(mobilNumber)
                .fillW2BClientEmail(clientEmail)
                .clickW2BSubmit()
                .checkW2BSuccessMessage();
    }

    public Function<Web2Branch, Web2Branch> fillW2BICO(int visitDay, int visitTime, String clientFullName, String clientICO, String mobilNumber, String clientEmail) {
        return start -> start
                .clickVisitDay()
                .selectVisitDay(visitDay)
                .clickVisitTime()
                .selectVisitTime(visitTime)
                .clickW2BContinue()
                .fillW2BClientFullName(clientFullName)
                .fillW2BClientICO(clientICO)
                .fillW2BClientPhoneNumber(mobilNumber)
                .fillW2BClientEmail(clientEmail)
                .clickW2BSubmit()
                .checkW2BSuccessMessage();
    }
}