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

import cz.moneta.test.dsl.Harness;
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.main.BAL035_S002_SummaryOfProductFoundationRetailPage.BAL035_S002_PAGE_LABEL_XPATH;

@Wait(value = BAL035_S002_PAGE_LABEL_XPATH, by = Lookup.XPATH, waitSecondsForElement = 60)
public interface BAL035_S002_SummaryOfProductFoundationRetailPage extends WebFlow<BAL035_S002_SummaryOfProductFoundationRetailPage>, StoreAccessor {
    String BAL035_S002_PAGE_LABEL_XPATH = "//div[text()='BAL035_S002']";

    String REQUEST_SWITCHING_CHECKBOX = "BAL035_S002_H005_1";
    String ARRANGE_APPOINTMENT_CHECKBOX = "BAL035_S002_H006_1";
    String ARRANGE_APPOINTMENT_XPATH = "//input[@name='BAL035_S002_H006']";
    String OK_BUTTON = "BAL035_S002_B001";

    @Click(value = ARRANGE_APPOINTMENT_CHECKBOX, jsClick = true)
    BAL035_S002_SummaryOfProductFoundationRetailPage clickArrangeAppointmentCheckbox();

    @CustomAction
    default BAL035_S002_SummaryOfProductFoundationRetailPage clickArrangeAppointmentIfChecked() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        if (endpoint.getAttribute(ARRANGE_APPOINTMENT_XPATH, Lookup.XPATH, "value").equals("1")) {
            endpoint.jsClick(() -> ARRANGE_APPOINTMENT_CHECKBOX);
        }
        return null;
    }

    @Click(REQUEST_SWITCHING_CHECKBOX)
    BAL035_S002_SummaryOfProductFoundationRetailPage clickRequestSwitchingCheckbox();

    @Click(OK_BUTTON)
    BAL035_S002_SummaryOfProductFoundationRetailTransitionPage clickContinueButton();
}
