package cz.moneta.test.dsl.ib.loans.flexicredit.request;

import cz.moneta.test.dsl.ib.IbPageFlow;
import cz.moneta.test.dsl.ib.loans.flexicredit.FlexicreditApplicationPage;
import cz.moneta.test.dsl.ib.loans.flexicredit.contract.FlexicreditOverdraftAmountPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Lookup;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.ib.loans.flexicredit.request.RequestConfirmationFlexicreditApplicationPage.CONFIRM_HEADER_TEXT;
import static cz.moneta.test.dsl.ib.loans.flexicredit.request.RequestConfirmationFlexicreditApplicationPage.EDUCATION;
import static cz.moneta.test.dsl.ib.loans.flexicredit.request.RequestConfirmationFlexicreditApplicationPage.HOUSING;
import static cz.moneta.test.dsl.ib.loans.flexicredit.request.RequestConfirmationFlexicreditApplicationPage.MARITAL_STATUS;
import static cz.moneta.test.dsl.ib.loans.flexicredit.request.RequestConfirmationFlexicreditApplicationPage.NATIONALITY;

@Wait({CONFIRM_HEADER_TEXT, EDUCATION, MARITAL_STATUS, NATIONALITY, HOUSING})
public interface RequestConfirmationFlexicreditApplicationPage extends IbPageFlow<RequestConfirmationFlexicreditApplicationPage>, FlexicreditApplicationPage, StoreAccessor {
    String CONFIRM_HEADER_TEXT = "//span[text() = 'Teď už jen drobnosti']";

    String EDUCATION = "//span[text()='Dosažené vzdělání']//parent::label//following::input[@name= 'education']";
    String MARITAL_STATUS = "//span[text()='Rodinný stav']//parent::label//following::input[@name= 'maritalStatus']";
    String NATIONALITY = "//span[text()='Státní příslušnost']//parent::label//following::input[@name= 'nationality']";
    String SECOND_DOCUMENT_TYPE = "react-select-10-input";
    String SECOND_DOCUMENT_VALUE = "//div[contains(@id, 'react-select-10-option') and text() = '%s']";
    String HOUSING = "//span[text()='Druh bydlení']//parent::label//following::input[@name= 'housing']";

    String AGREE_AND_CONTINUE = "//span[text() = 'Souhlasím, pokračovat']//parent::button";

    @Click(value = AGREE_AND_CONTINUE, jsClick = true)
    FlexicreditOverdraftAmountPage agreeAndContinueToOverdraftAmount();

    @Wait(value = SECOND_DOCUMENT_TYPE, by = Lookup.ID)
    @Click(value = SECOND_DOCUMENT_TYPE, by = Lookup.ID, jsClick = true)
    @Wait(value = SECOND_DOCUMENT_VALUE, isStringDynamicXpath = true)
    @Click(value = SECOND_DOCUMENT_VALUE, isStringDynamicXpath = true)
    RequestConfirmationFlexicreditApplicationPage setSecondDocument(String secondDocument);
}
