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

import cz.moneta.test.dsl.ufo.banka.pages.fon.TIS050_S001_SignerSelectionPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ufo.banka.pages.insurance.IDD001_S001_IndividualInsuranceFormPage.IDD001_S001_PAGE_LABEL_XPATH;
import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;

@Wait(value = IDD001_S001_PAGE_LABEL_XPATH, by = Lookup.XPATH)
public interface IDD001_S001_IndividualInsuranceFormPage extends WebFlow<IDD001_S001_IndividualInsuranceFormPage>, StoreAccessor {
    String IDD001_S001_PAGE_LABEL_XPATH = "//div[text()='IDD001_S001']";
    String NEW_CONTRACT_BUTTON = "IDD001_S001_B003";
    String INSURANCE_TYPE_RADIO_BUTTON_LIFE = "IDD001_S001_R003_LIFE";
    String INSURED_RADIO_ME = "IDD001_S001_R004_1";
    String BENEFICIARY_RADIO_ME = "IDD001_S001_R015_1";
    String MARITAL_STATUS_RADIO_SINGLE = "IDD001_S001_R009_1";
    String OCCUPATION_SELECT = "IDD001_S001_C002";
    String ACTIVITY_SELECT = "IDD001_S001_C003";
    String INCOME_INPUT = "IDD001_S001_E008";
    String EXPENSES_INPUT = "IDD001_S001_E011";
    String SECURING_LOANS_NO = "IDD001_S001_R016_0";
    String FINANCIAL_RESERVE_RADIO_SIX_MONTHS = "IDD001_S001_R011_3";
    String FINANCIAL_RESOURCES_FOR_BETTER_TREATMENT_RADIO_YES = "IDD001_S001_R017_1";
    String MONTHLY_ANNUITY_RADIO_NO = "IDD001_S001_R018_0";
    String DAILY_ANNUITY_RADIO_NO = "IDD001_S001_R008_0";
    String PERSONAL_DATA_AGREEMENT = "IDD001_S001_R010_1";
    String REMOTE_BANKER_RADIO_NO = "IDD001_S001_R002_0";
    String ELECTRONIC_FORM_RADIO_YES = "IDD001_S001_R006_0";
    String CALCULATE_INSURANCE_RISK_BUTTON = "IDD001_S001_B008";
    String SAVE_INSURANCE_RISK_BUTTON = "IDD001_S001_B009";
    String CONTINUE_TO_SIGN_BUTTON = "IDD001_S001_B005";
    String OPEN_NN = "IDD001_S001_B001";

    @Click(NEW_CONTRACT_BUTTON)
    IDD001_S001_IndividualInsuranceFormPage clickNewContract();

    @Click(value = INSURANCE_TYPE_RADIO_BUTTON_LIFE, jsClick = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    IDD001_S001_IndividualInsuranceFormPage clickLifeInsurance();

    @Click(value = INSURED_RADIO_ME, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickMeAsInsured();

    @Click(value = BENEFICIARY_RADIO_ME, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickMeAsBeneficiary();

    @Click(value = MARITAL_STATUS_RADIO_SINGLE, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickMaritalStatusSingle();

    @Select(OCCUPATION_SELECT)
    IDD001_S001_IndividualInsuranceFormPage selectOccupation(String value);

    @Select(ACTIVITY_SELECT)
    IDD001_S001_IndividualInsuranceFormPage selectActivity(String value);

    @TypeInto(INCOME_INPUT)
    IDD001_S001_IndividualInsuranceFormPage fillIncome(String income);

    @TypeInto(EXPENSES_INPUT)
    IDD001_S001_IndividualInsuranceFormPage fillExpenses(String expenses);

    @Click(value = SECURING_LOANS_NO, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickSecuringLoansNo();

    @Click(value = FINANCIAL_RESERVE_RADIO_SIX_MONTHS, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickFinancialReserveSixMonths();

    @Click(value = FINANCIAL_RESOURCES_FOR_BETTER_TREATMENT_RADIO_YES, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickBetterTreatment();

    @Click(value = MONTHLY_ANNUITY_RADIO_NO, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickNotMonthlyAnnuity();

    @Click(value = DAILY_ANNUITY_RADIO_NO, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickDailyAnnuityNo();

    @Click(value = PERSONAL_DATA_AGREEMENT, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickPersonalDataAgreementYes();

    @Click(value = REMOTE_BANKER_RADIO_NO, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickNoRemoteBanker();

    @Click(value = ELECTRONIC_FORM_RADIO_YES, jsClick = true)
    IDD001_S001_IndividualInsuranceFormPage clickElectronicForm();

    @Click(value = CALCULATE_INSURANCE_RISK_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    IDD001_S001_IndividualInsuranceFormPage clickCalculateInsuranceRisk();

    @Click(SAVE_INSURANCE_RISK_BUTTON)
    IDD001_S001_IndividualInsuranceFormPage clickSaveInsuranceRisk();

    @Click(CONTINUE_TO_SIGN_BUTTON)
    TIS050_S001_SignerSelectionPage clickContinueToSign();

    @CustomAction
    default StelaNnLifeInsurancePage clickOpenNNAndSwitchTab() {
        UfoEndpoint e = getEndpoint(UfoEndpoint.class);
        e.waitForElementsToLoad(30, Lookup.CLASSNAME, Until.GONE, LOAD_IMG_DIV_CLASS);
        e.click(() -> OPEN_NN);
        e.switchToOtherWindow(1, 2);
        return null;
    }
}