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

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.fon.ZAS003_S001_ChooseLegalRepresentativePage.CHILD_LEGAL_REPRESENTATIVE_PAGE_LABEL_XPATH;

@Wait(value = CHILD_LEGAL_REPRESENTATIVE_PAGE_LABEL_XPATH, by = Lookup.XPATH, waitSecondsForElement = 30)
public interface ZAS003_S001_ChooseLegalRepresentativePage extends WebFlow<ZAS003_S001_ChooseLegalRepresentativePage>, StoreAccessor {

    String CHILD_LEGAL_REPRESENTATIVE_PAGE_LABEL_XPATH = "//div[text()='ZAS003_S001']";
    String FIRST_REPRESENTATIVE_CHECKBOX = "ZAS003_S001_G001-0";
    String SECOND_REPRESENTATIVE_CHECKBOX = "ZAS003_S001_G001-1";
    String CONTINUE_BUTTON = "ZAS003_S001_B002";

    @Click(FIRST_REPRESENTATIVE_CHECKBOX)
    ZAS003_S001_ChooseLegalRepresentativePage clickFirstRepresentative();

    @Click(SECOND_REPRESENTATIVE_CHECKBOX)
    ZAS003_S001_ChooseLegalRepresentativePage clickSecondRepresentative();

    @CustomAction
    default ZAS003_S001_ChooseLegalRepresentativePageTransitions clickContinueToMainClientPageAndCloseAlertIfVisible() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> CONTINUE_BUTTON);
        if (endpoint.isAlertPresent(3)) {
            endpoint.dismissAlert(1);
        }
        return null;
    }

    @Click(CONTINUE_BUTTON)
    ZAS003_S001_ChooseLegalRepresentativePageTransitions clickContinue();
}
