package cz.moneta.test.dsl.exevido.components;

import cz.moneta.test.dsl.exevido.DataBoxType;
import cz.moneta.test.dsl.exevido.pages.LoginPage;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.exevido.components.ExevidoPanels.LOADER_DIV;
import static cz.moneta.test.dsl.exevido.components.SmallBoxes.NOTIFICATIONS_XPATH;
import static cz.moneta.test.dsl.exevido.components.TopMenu.EXEVIDO_LOGO;

@Wait(EXEVIDO_LOGO)
@Wait(value = LOADER_DIV, until = Until.GONE)
public interface TopMenu<T> {

    String EXEVIDO_LOGO = "logo";
    String CHOOSE_DATA = "choose_data_box";
    String COMPANY_SELECT_BOX = "company_id";
    String COMPANY_MMB_XPATH = "//div[contains(@title, 'MONETA Money Bank, a.s. - 25672720')]";
    String COMPANY_MSS_XPATH = "//div[contains(@title, 'MONETA Stavební Spořitelna, a.s. - 47115289')]";
    String DATA_BOX_SELECT_BOX = "databox_select";
    String DATA_BOX_XPATH = "//div[contains(@title, '%1$s')]";
    String ADD_DATA_BOX_BUTTON = "addDatabox";
    String LOG_OUT_BUTTON = "logout_btn";
    String CONFIRM_BUTTON = "confirm_button";

    @Wait(value = NOTIFICATIONS_XPATH, until = Until.GONE)
    @Click(CHOOSE_DATA)
    TopMenu<T> clickChooseDataBox();

    @Click(value = COMPANY_SELECT_BOX)
    TopMenu<T> clickSelectCompanyBox();

    @Click(value = COMPANY_MMB_XPATH, by = Lookup.XPATH)
    TopMenu<T> clickCompanyMMB();

    @Click(value = COMPANY_MSS_XPATH, by = Lookup.XPATH)
    TopMenu<T> clickCompanyMSS();

    @Click(DATA_BOX_SELECT_BOX)
    TopMenu<T> clickSelectDataBox();

    @Click(value = DATA_BOX_XPATH, by = Lookup.XPATH)
    TopMenu<T> clickDataBox(DataBoxType dataBoxType);

    @Click(value = ADD_DATA_BOX_BUTTON, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    T addDataBox();

    @Click(LOG_OUT_BUTTON)
    @Click(CONFIRM_BUTTON)
    LoginPage logOutFromExevido();

}