package cz.moneta.test.dsl.ib.accountsandtransactions.paymentawaitingsignature;

import cz.moneta.test.dsl.ib.IbPageFlow;
import cz.moneta.test.dsl.ib.components.MainMenu;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.ib.accountsandtransactions.paymentawaitingsignature.PaymentsAwaitingSignature.NAME_OF_PAGE;
import static cz.moneta.test.dsl.ib.accountsandtransactions.paymentawaitingsignature.PaymentsAwaitingSignature.SEARCH_BY_FLIED_XPATH;

@Wait({NAME_OF_PAGE, SEARCH_BY_FLIED_XPATH})
public interface PaymentsAwaitingSignature extends IbPageFlow<PaymentsAwaitingSignature>, MainMenu {
    String SELECT_ALL_CHECKBOX = "//input[@name='selectAll']";
    String SIGN_BUTTON = "//img[@id='sendToSign']";
    String LOADER_DIV = "//div[@class='busyLoader' and @style='display: block;']";
    String SEARCH_BY_FLIED_XPATH = "//div[@id='filterLeft']//following::span[contains(text(), 'Vyhledat podle')]";
    String EMAIL_NOTIFY_FIELD_XPATH = "//div[@id='mailNotifyRight']//following::span[contains(text(), 'E-mailová upozornění')]";
    String NAME_OF_PAGE = "//img[@alt='Platby k podpisu']";
    String FIRST_PAYMENT_CHECKBOX = "//tr[@id='a1']/descendant::input";
    String REJECT_BUTTON = "//img[@alt='Zamítnout vybrané']";
    String AUTHOR_PAYMENT_SELECT = "//select[@id='creator']/option[contains(text(),'%s')]";
    String SHOW_BUTTON = "//img[@id='filterBtnUp']";
    String LOADER = "//div[@class='busyLoaderImg']";
    String FIRST_PAYMENT_BY_AUTHOR_PAYMENT_IN_TABLE = "(//td[@class='listItem' and contains(.,'%s')]/following-sibling::td/descendant::input)[1]";

    @Click(value = SELECT_ALL_CHECKBOX, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    PaymentsAwaitingSignature clicSelectAll();

    @Click(SIGN_BUTTON)
    PaymentsAwaitingSignatureConfirmationPage clicSignSelected();

    @Click(SIGN_BUTTON)
    PaymentsAwaitingSignatureAuthorizePage clickSignSelectedButton();

    @Click(REJECT_BUTTON)
    PaymentsAwaitingSignatureAuthorizePage clickRejectSelectedButton();

    @Click(FIRST_PAYMENT_CHECKBOX)
    PaymentsAwaitingSignature selectFirstPayment();

    @Click(value = AUTHOR_PAYMENT_SELECT, isStringDynamicXpath = true)
    @Click(value = SHOW_BUTTON, andWait = @Wait(value = LOADER, until = Until.GONE))
    PaymentsAwaitingSignature selectAuthorPaymentAndClickShowButton(String authorPayment);

    @Click(value = FIRST_PAYMENT_BY_AUTHOR_PAYMENT_IN_TABLE, isStringDynamicXpath = true)
    PaymentsAwaitingSignature selectFirstPaymentByAuthor(String nameOfAuthorPayment);
}
