package cz.moneta.test.dsl.ufo.operations.search;

import cz.moneta.test.dsl.earchiv.StatementsPage;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.EMA701_S001_ManualApprovingQueue;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.EXE704_S001_CancelPaymentOrderPage;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.EXE705_S001_PaymentRecordsToApprovePage;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.TRA740_S001_CreateNewTransferPaymentOrderPage;
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 OPS001_S001_LeftMenu extends Builder, StoreAccessor {

    String BLACKLIST_WHITELIST_BUTTON = "OPS001_S001_I004";
    String SEARCH_AP_RISK_BUTTON = "OPS001_S001_I043";
    String MANUAL_APPROVING_BUTTON = "OPS001_S001_I054";
    String TRANSFER_PAYMENTS_ORDER_DIV = "OPS001_S001_I032";
    String CREATE_NEW_TRANSFER_PAYMENT_ORDER_DIV = "OPS001_S001_I034";
    String CANCEL_PAYMENT_ORDER_DIV = "OPS001_S001_I142";
    String TRANSFER_PAYMENT_VERIFICATION_DIV = "OPS001_S001_I078";
    String EARCHIV_BUTTON = "//div[@id='OPS001_S001_I121' and @class='ufo-MenuItem ufo-MenuItem-vertical']";
    String EARCHIV_BUTTON_FOCUSED = "//div[@id='OPS001_S001_I121' and @class='ufo-MenuItem ufo-MenuItem-vertical ufo-MenuItem-selected']";

    @Click(BLACKLIST_WHITELIST_BUTTON)
    BLK701_S001_BlacklistWhitelist clickBlacklistWhitelist();

    @Click(SEARCH_AP_RISK_BUTTON)
    SCH704_S001_ClientSearchApRisk clickSearchApRisk();

    @Click(MANUAL_APPROVING_BUTTON)
    EMA701_S001_ManualApprovingQueue clickRiskManualApprovingQueue();

    @Click(TRANSFER_PAYMENTS_ORDER_DIV)
    @Click(value = CREATE_NEW_TRANSFER_PAYMENT_ORDER_DIV, jsClick = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    TRA740_S001_CreateNewTransferPaymentOrderPage clickCreateNewTransferPaymentOrder();

    @Click(TRANSFER_PAYMENTS_ORDER_DIV)
    @Click(value = CANCEL_PAYMENT_ORDER_DIV, jsClick = true)
    EXE704_S001_CancelPaymentOrderPage clickCancelPaymentOrder();

    @Click(TRANSFER_PAYMENTS_ORDER_DIV)
    @Click(value = TRANSFER_PAYMENT_VERIFICATION_DIV, jsClick = true)
    EXE705_S001_PaymentRecordsToApprovePage clickTransferPaymentOrderVerification();

    @CustomAction
    default StatementsPage clickEarchiv() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.moveToElementAndClickToOtherElement(EARCHIV_BUTTON, EARCHIV_BUTTON_FOCUSED, Lookup.XPATH);
        endpoint.switchToOtherWindow(5, 2);
        return null;
    }

}