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

import cz.moneta.test.dsl.exevido.pages.inheritance.FoldersPage;
import cz.moneta.test.dsl.exevido.pages.IncomingMessagesPage;
import cz.moneta.test.dsl.exevido.pages.OutgoingMessagesPage;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Lookup;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.exevido.components.ExevidoPanels.LOADER_DIV;
import static cz.moneta.test.dsl.exevido.components.LeftMenu.PAGE_SA_SMART_MENU;
import static cz.moneta.test.dsl.exevido.pages.inheritance.FoldersPage.PAGE_LABEL_XPATH;

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

    String PAGE_SA_SMART_MENU = "sasmartmenu";
    String CATEGORY_MY_MESSAGES = "my_link";
    String SUBCATEGORY_FOR_CHECK = "myForCheck";
    String CATEGORY_INCOMING_MESSAGES = "incoming_messages_link";
    String SUBCATEGORY_ALL_INCOMING_MESSAGES_A = "all_incoming_messages";
    String CATEGORY_OUTGOING_MESSAGES = "outgoing_messages_link";
    String SUBCATEGORY_ALL_OUTGOING_MESSAGES_A = "all_outgoing_messages_link";
    String CATEGORY_INHERITANCE_MMB_XPATH = "//li[@id='Dědictví - MMB']";
    String SUBCATEGORY_WITHOUT_FOLDER_XPATH = CATEGORY_INHERITANCE_MMB_XPATH + "//a[contains(., 'Bez spisu')]";
    String SUBCATEGORY_FOR_PROCESSING_XPATH = CATEGORY_INHERITANCE_MMB_XPATH + "//a[contains(., 'Ke zpracování')]";
    String SUBCATEGORY_FOLDERS_XPATH = CATEGORY_INHERITANCE_MMB_XPATH + "//a[contains(., 'Spisy')]";
    String FOR_PROCESSING_D_REQUEST_MMB_XPATH = CATEGORY_INHERITANCE_MMB_XPATH + "//a[contains(., 'D - Žádost [M] - MMB')]";
    String REFRESH_COUNTERS_BUTTON = "refresh_counters";

    @Click(value = CATEGORY_MY_MESSAGES, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    IncomingMessagesPage clickMyMessages();

    @Click(value = SUBCATEGORY_FOR_CHECK, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    OutgoingMessagesPage clickForCheckMessages();

    @Click(value = CATEGORY_INCOMING_MESSAGES, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    IncomingMessagesPage clickIncomingMessages();

    @Click(value = SUBCATEGORY_ALL_INCOMING_MESSAGES_A, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    IncomingMessagesPage clickAllIncomingMessages();

    @Click(value = CATEGORY_OUTGOING_MESSAGES, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    OutgoingMessagesPage clickOutgoingMessages();

    @Click(SUBCATEGORY_ALL_OUTGOING_MESSAGES_A)
    OutgoingMessagesPage clickAllOutgoingMessages();

    @Click(value = CATEGORY_INHERITANCE_MMB_XPATH, by = Lookup.XPATH, andWait = @Wait(value = SUBCATEGORY_WITHOUT_FOLDER_XPATH, by = Lookup.XPATH, until = Until.VISIBLE))
    @Click(value = SUBCATEGORY_WITHOUT_FOLDER_XPATH, by = Lookup.XPATH, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    IncomingMessagesPage clickInheritanceMmbWithoutFolder();

    @Click(value = CATEGORY_INHERITANCE_MMB_XPATH, by = Lookup.XPATH, andWait = @Wait(value = SUBCATEGORY_FOR_PROCESSING_XPATH, by = Lookup.XPATH, until = Until.VISIBLE))
    @Click(value = SUBCATEGORY_FOR_PROCESSING_XPATH, by = Lookup.XPATH, andWait = @Wait(value = FOR_PROCESSING_D_REQUEST_MMB_XPATH, by = Lookup.XPATH, until = Until.VISIBLE))
    LeftMenu clickInheritanceMmbForProcessing();

    @Click(value = CATEGORY_INHERITANCE_MMB_XPATH, by = Lookup.XPATH, andWait = @Wait(value = SUBCATEGORY_FOR_PROCESSING_XPATH, by = Lookup.XPATH, until = Until.VISIBLE))
    @Click(value = SUBCATEGORY_FOLDERS_XPATH, by = Lookup.XPATH, andWait = @Wait(value = PAGE_LABEL_XPATH, by = Lookup.XPATH, until = Until.VISIBLE))
    FoldersPage clickInheritanceMmbFolders();

    @Click(value = FOR_PROCESSING_D_REQUEST_MMB_XPATH, by = Lookup.XPATH, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    IncomingMessagesPage clickRequestMmb();

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

}