package cz.moneta.test.dsl.ufo.banka.pages.main.client.settings;

import cz.moneta.test.harness.endpoints.WebEndpoint;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ufo.banka.pages.main.client.settings.ADR004_S001_EnterContactAddressPage.ADR004_S001_PAGE_LABEL_XPATH;
import static cz.moneta.test.dsl.ufo.banka.pages.main.client.settings.ADR004_S001_EnterContactAddressPage.USE_RESIDENCY_ADDRESS_AS_CONTACT_CHECKBOX;

@Wait(value = ADR004_S001_PAGE_LABEL_XPATH, by = Lookup.XPATH, waitSecondsForElement = 80)
@Wait(value = USE_RESIDENCY_ADDRESS_AS_CONTACT_CHECKBOX, waitSecondsForElement = 80)
public interface ADR004_S001_EnterContactAddressPage extends WebFlow<ADR004_S001_EnterContactAddressPage> {
    String ADR004_S001_PAGE_LABEL_XPATH = "//div[text()='ADR004_S001']";
    String USE_RESIDENCY_ADDRESS_AS_CONTACT_CHECKBOX = "ADR004_S001_H001_1";
    String CONTACT_ADDRESS_CONFIRM_BUTTON = "ADR004_S001_B006";
    String SAVE_BUTTON = "ADR004_S001_B003";
    String MODAL_CONTACT_ADDRESS_WINDOW_ID = "ADR004_S001_FB002";

    default void loadPage(WebEndpoint endpoint) {
        if (endpoint.isAlertPresent(3)) {
            endpoint.dismissAlert(80);
        }
    }

    @Click(
            value = USE_RESIDENCY_ADDRESS_AS_CONTACT_CHECKBOX,
            andWait = @Wait(value = MODAL_CONTACT_ADDRESS_WINDOW_ID, until = Until.VISIBLE, waitSecondsForElement = 60)
    )
    @Click(
            value = CONTACT_ADDRESS_CONFIRM_BUTTON,
            andWait = @Wait(value = MODAL_CONTACT_ADDRESS_WINDOW_ID, until = Until.GONE, waitSecondsForElement = 60)
    )
    ADR004_S001_EnterContactAddressPage clickUseResidencyAsContactAndConfirm();

    @Click(SAVE_BUTTON)
    ADR004_S001_EnterContactAddressPageTransitions clickSave();
}
