package cz.moneta.test.dsl.monetaportal.savings.childbuildingsavings;

import cz.moneta.test.harness.endpoints.ib.NewIbEndpoint;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Wait;
import cz.moneta.test.harness.support.web.Waits;

import static cz.moneta.test.dsl.monetaportal.savings.childbuildingsavings.AdditionalInformationPage.NATIONALITY_NUMBER_WITH_VALUE;
import static cz.moneta.test.dsl.monetaportal.savings.childbuildingsavings.AdditionalInformationPage.PAGE_HEADER;

@Waits({@Wait(PAGE_HEADER), @Wait(NATIONALITY_NUMBER_WITH_VALUE)})
public interface AdditionalInformationPage extends ChildBuildingSavingsPageFlow<AdditionalInformationPage> {
    String PAGE_HEADER = "//h2[text()='Dodatečné informace']";
    String NATIONALITY_NUMBER_WITH_VALUE = "//button[@id='nationality_button' and string-length(@data-value) > 0]";
    String BIRTH_COUNTRY = "//button[@name='birthCountry']";
    String BIRTH_COUNTRY_OPTION = "//div[@class='c-dropdown__itemContent' and contains(text(),'%s')]";
    String PEP_YES = "//li[@id='pep_value-true']";
    String PEP_NO = "//li[@id='pep_value-false']";

    @Click(PEP_YES)
    AdditionalInformationPage clickPepYes();

    @Click(PEP_NO)
    AdditionalInformationPage clickPepNo();

    @CustomAction
    default AdditionalInformationPage setBirthCountry(String birthCountry) {
        NewIbEndpoint ep = getEndpoint(NewIbEndpoint.class);
        ep.jsClick(() -> BIRTH_COUNTRY);
        ep.jsClick(() -> String.format(BIRTH_COUNTRY_OPTION, birthCountry));
        return null;
    }

    @Click(CONTINUE_BUTTON)
    LawFormPage clickContinue();
}