package cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_clients;

import cz.moneta.test.dsl.payment_engine.home.PaymentEngineHomePage;
import cz.moneta.test.harness.support.web.*;

public interface PaymentEngineClientsListOfStandingOrders extends WebFlow<PaymentEngineClientsListOfStandingOrders> {
    String DEBTOR_ACC = "//input[@name = 'orAcc']";
    String CREDITOR_ACC = "//input[@name = 'cpAcc']";
    String ID = "//input[@name = 'id']";
    String SELECT_STATUS = "//input[@name = 'status']//following-sibling::img";
    String STATUS_NULL = "//div[text()='Archivovaný']/preceding-sibling::div";
    String STATUS_FOR_VERIFICATION = "//div[text()='Ke schválení']";
    String APPLY_BUTTON = "//button[text() = 'Aplikovat']";
    String APPROVE_BUTTON = "//a[text() = 'Schválit']";
    String EDIT_BUTTON = "//a[text() = 'Editovat']";
    String DELETE_BUTTON = "//a[text() = 'Vymazat']";
    String TRANSACTIONS_BUTTON = "//a[text() = 'Transakce']";
    String STAND_ORDER_ROOT_ID_XPATH = "//div[@class='x-grid3-cell-inner x-grid3-col-1']";
    String STAND_ORDER_ROOT_ID_KEY = "STAND_ORDER_ROOT_ID_KEY";
    String CHECK_STATUS = "//div[@class='x-grid3-cell-inner x-grid3-col-16']";
    String OK_BUTTON = "//button[text() = 'OK']";
    String CLOSE_TAB = "//a[@class = 'x-tab-strip-close']";
    String AMOUNT = "//input[@type='text' and @name='amount']";
    String AJAX_LOADING = "//div[text()='Načítám...']";
    String BANK_CODE_INPUT = "//input[@name = 'cpBankCode']//following-sibling::img";
    String INHOUSE_BANK_CODE = "//div[@class='x-combo-list-inner']/div[text()='0600 - MONETA Money Bank, a.s.']";

    @TypeIntos({@TypeInto(DEBTOR_ACC), @TypeInto(CREDITOR_ACC)})
    PaymentEngineClientsListOfStandingOrders fillSearchData(String debtorAcc, String creditorAcc);

    @Click(value = APPLY_BUTTON, andWait = @Wait(value = AJAX_LOADING, until = Until.GONE))
    PaymentEngineClientsListOfStandingOrders clickApply();

    @Click(value = APPROVE_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.VISIBLE))
    PaymentEngineClientsListOfStandingOrders clickApprove();

    @StoreElementContent(storeKey = STAND_ORDER_ROOT_ID_KEY, value = STAND_ORDER_ROOT_ID_XPATH, by = Lookup.XPATH)
    PaymentEngineClientsListOfStandingOrders storeRootId();

    @Wait(value = AJAX_LOADING, until = Until.GONE)
    @Click(value = SELECT_STATUS)
    PaymentEngineClientsListOfStandingOrders clickOnStatus();

    @Wait(STATUS_FOR_VERIFICATION)
    @Click(STATUS_FOR_VERIFICATION)
    PaymentEngineClientsListOfStandingOrders selectStatusForVerification();

    @Wait(STATUS_NULL)
    @Click(STATUS_NULL)
    PaymentEngineClientsListOfStandingOrders selectStatusNull();

    @TypeInto(ID)
    PaymentEngineClientsListOfStandingOrders fillId(String rootId);

    @CheckElementPresent(value = CHECK_STATUS, isStringDynamicXpath = true)
    @Wait(explicitWaitSeconds = 2)
    PaymentEngineClientsListOfStandingOrders checkStatus(String status);

    @Click(value = CLOSE_TAB, andWait = @Wait(explicitWaitSeconds = 1))
    PaymentEngineHomePage closeTab();

    @Click(value = EDIT_BUTTON, andWait = @Wait(value = AMOUNT, until = Until.VISIBLE))
    PaymentEngineClientsListOfStandingOrders clickEdit();

    @TypeInto(value = AMOUNT, andWait = @Wait(value = OK_BUTTON, until = Until.CLICKABLE))
    PaymentEngineClientsListOfStandingOrders editStandingOrder(String amount);

    @Click(value = OK_BUTTON, andWait = @Wait(value = EDIT_BUTTON, until = Until.VISIBLE))
    PaymentEngineClientsListOfStandingOrders clickOk();

    @Click(value = DELETE_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.VISIBLE))
    PaymentEngineClientsListOfStandingOrders clickDelete();

    @Click(value = TRANSACTIONS_BUTTON, andWait = @Wait(value = AJAX_LOADING, until = Until.GONE))
    PaymentEngineClientsListOfStandingOrdersTransactions clickOnTransactions();
}
