package cz.moneta.test.dsl.ufo.operations.shared.topmenu;

import cz.moneta.test.dsl.ufo.banka.pages.search.HLO001_S001_ClientSearchPage;
import cz.moneta.test.dsl.ufo.operations.client.product.KOK701_S001_MeetingSchedulingPage;
import cz.moneta.test.dsl.ufo.operations.recorder.CRC710_S001_RecorderMainPage;
import cz.moneta.test.dsl.ufo.operations.search.OPS001_S001_ClientSearchPageUfoOperations;
import cz.moneta.test.dsl.ufo.operations.shared.LogOutPage;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.ETS701_S001_ClientDocuments;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.KAL730_S001_CalculatorPage;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.SET701_S001_AuthorizationOverview;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.UKO720_S001_TaskList;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.contactForwarding.XCM701_S001_ContactForwardingPage;
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.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;

public interface XXX701_SharedTopMenu<T> extends StoreAccessor {

    String SSO_OF_LOGGED_USER = "//div[@id='XXX701_T001']/input[@name='SSO']";

    String HOMEPAGE_BUTTON = "XXX701_T001_P007";
    String CORRESPONDENCE_BUTTON = "XXX701_T001_P027";
    String MEETINGS_AND_SMS_BUTTON = "XXX701_T001_P028";
    String CONTACT_FORWARDING_BUTTON = "XXX701_T001_P018";
    String RECORDER_APP_BUTTON = "XXX701_T001_P024";
    String CALCULATOR_BUTTON = "XXX701_T001_P010";
    String TASKS_BUTTON = "XXX701_T001_P025";

    String APPLICATION_SELECT_BUTTON = "XXX701_T001_P003";
    String APPLICATION_SELECT_UFO_BANKA_BUTTON = "XXX701_T001_P005-1";


    String STATUS_LABEL = "XXX701_T001_L030";
    String SETTINGS_BUTTON = "XXX701_T001_P001";
    String LOGOUT_BUTTON = "XXX701_T001_B008";



    @Click(value = HOMEPAGE_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    OPS001_S001_ClientSearchPageUfoOperations clickHomePage();

    @CustomAction
    default ETS701_S001_ClientDocuments clickCorrespondence() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> CORRESPONDENCE_BUTTON);
        endpoint.focusToNewPopup(10);
        return null;
    }

    @Click(MEETINGS_AND_SMS_BUTTON)
    KOK701_S001_MeetingSchedulingPage clickMeetingsAndSms();

    @Click(CONTACT_FORWARDING_BUTTON)
    XCM701_S001_ContactForwardingPage clickContactForwarding();

    @CustomAction
    default CRC710_S001_RecorderMainPage clickRecorder() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> RECORDER_APP_BUTTON);
        endpoint.focusToNewPopup(10);
        return null;
    }

    @Click(CALCULATOR_BUTTON)
    KAL730_S001_CalculatorPage clickCalculator();

    @Click(value = TASKS_BUTTON, jsClick = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, waitSecondsForElement = 30, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskList clickTasks();

    @Click(APPLICATION_SELECT_BUTTON)
    OPS001_S001_ClientSearchPageUfoOperations clickChangeApplication();

    @Click(APPLICATION_SELECT_UFO_BANKA_BUTTON)
    HLO001_S001_ClientSearchPage clickUfoBanka();

    @CheckElementContent(STATUS_LABEL)
    T assertStatusLabel(String expectedStatus);

    @Click(value = SETTINGS_BUTTON)
    SET701_S001_AuthorizationOverview clickSettings();

    @Click(LOGOUT_BUTTON)
    LogOutPage clickLogout();

}
