package cz.moneta.test.dsl.ufo.banka.tasks.insurance;

import cz.moneta.test.dsl.ufo.banka.pages.insurance.PIP001_S001_ChooseInsurancePage;
import cz.moneta.test.dsl.ufo.banka.pages.main.HKO101_S001_MainClientPage;
import cz.moneta.test.dsl.ufo.banka.pages.search.HLO001_S001_ClientSearchPage;

import java.util.function.Function;

import static cz.moneta.test.dsl.ufo.banka.pages.main.codelists.HCisProductClass.INSURANCE;

public class InsuranceGroupTasks {

    public Function<HLO001_S001_ClientSearchPage, PIP001_S001_ChooseInsurancePage> findCifAndCreateGroupInsuranceProduct(String cifNumber, String productName, String accountNumber) {
        return start -> start.fillSearchTerm(cifNumber)
                .clickSearchByCif()
                .onClientDetailPage()
                .createNewProduct(INSURANCE)
                .onInsuranceSelectPage()
                .clickGroupInsuranceButtonAndContinueToChooseInsurancePage()
                .selectInsurance(productName)
                .selectAccount(accountNumber);
    }

    public Function<PIP001_S001_ChooseInsurancePage, HKO101_S001_MainClientPage> completeAndCheckActiveInsurance(String productNameToCheck) {
        return start -> start.clickContinue()
                .onSignerSelectionPage()
                .clickContinue()
                .onVerificationOfSignaturePage()
                .clickSignedButtonAndContinueToEnterIntoOtherInsurancePage()
                .clickFinishButtonAndContinueToDispositionsPage()
                .clickGenerateNow()
                .onContractDocumentationPage()
                .clickContinue()
                .onSummaryStartDocumentsPage()
                .clickContinue()
                .onMainClientPage()
                .checkProductActive(productNameToCheck);
    }
}