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

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.newCif.CIF111_S001_NewCifDataNavigation.CIF111_S001_PAGE_LABEL_XPATH;
import static cz.moneta.test.dsl.ufo.banka.pages.fon.newCif.CIF111_S001_NewCifDataNavigation.CONTINUE_BUTTON;

@Wait(value = CIF111_S001_PAGE_LABEL_XPATH, by = Lookup.XPATH)
@Wait({CONTINUE_BUTTON})
public interface CIF111_S001_NewCifDataNavigation extends WebFlow<CIF111_S001_NewCifDataNavigation>, Builder, StoreAccessor {
    String CIF111_S001_PAGE_LABEL_XPATH = "//div[text()='CIF111_S001']";

    String CONTINUE_BUTTON = "CIF111_S001_B015";
    String CLOSE_IDENTIFICATION_POPUP_BUTTON = "CIF111_S001_X383";

    String CONSENTS_PRODUCTS_AND_SERVICES = "//label[@for='CIF111_S001_H006_1']"; //CIF111_S001_H006_1
    String CONSENTS_ELECTRONIC_AND_SMS_NOTIFICATIONS = "//label[@for='CIF111_S001_H005_1']"; //"CIF111_S001_H005_1";
    String CONSENTS_WHATSAPP = "//label[@for='CIF111_S001_H008_1']"; //"CIF111_S001_H008_1";

    NewCifPersonalData fillPersonalIdentificationData();

    NewCifResidency fillResidency();

    NewCifContacts fillContacts();

    NewCifIdentificationDocuments fillIdentificationDocuments();

    NewCifEmployment fillEmployment();

    NewCifAdditionalInformation fillAdditionalInformation();

    NewCifRegistryChecks checkRegistryLoad();


    @Click(value = CONSENTS_PRODUCTS_AND_SERVICES, by = Lookup.XPATH)
    @Click(value = CONSENTS_ELECTRONIC_AND_SMS_NOTIFICATIONS, by = Lookup.XPATH)
    @Click(value = CONSENTS_WHATSAPP, by = Lookup.XPATH)
    CIF111_S001_NewCifDataNavigation clickConsents();

    @Click(CONTINUE_BUTTON)
    CIF111_S001_NewCifDataTransitions clickContinue();

    //PPE only
    @CustomAction
    default CIF111_S001_NewCifDataNavigation tryCloseIdentificationPopup() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        if (endpoint.isElementVisible(2, CLOSE_IDENTIFICATION_POPUP_BUTTON, Lookup.ID)) {
            endpoint.click(() -> CLOSE_IDENTIFICATION_POPUP_BUTTON, Lookup.ID);
        }
        return null;
    }
}
