package cz.moneta.test.dsl.ib.payment.domestic;

import cz.moneta.test.dsl.ib.IbPageFlow;
import cz.moneta.test.dsl.ib.components.AccountsAndTransactionsSubmenu;
import cz.moneta.test.dsl.ib.components.MainMenu;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ib.payment.domestic.PaymentOrderCreatePage.CONTINUE_BUTTON;
import static cz.moneta.test.dsl.ib.payment.domestic.PaymentOrderCreatePage.FROM_ACCOUNT_SELECT;

@Wait({FROM_ACCOUNT_SELECT, CONTINUE_BUTTON})
public interface PaymentOrderCreatePage extends IbPageFlow<PaymentOrderCreatePage>, MainMenu, AccountsAndTransactionsSubmenu {
    String TRANSFER_BETWEEN_OWN_ACCOUNTS = "//input[@name='DPOType' and @value='cat']";
    String MASS_PAYMENT = "//input[@name='DPOType' and @value='mpo']";
    String FROM_ACCOUNT_SELECT = "//select[@id='fromAccount']";
    String FROM_ACCOUNT_SELECT_BY_NAME = "//select[@id='fromAccount']/option[contains(text(),'%s')]";
    String FROM_FIRST_OWN_ACCOUNT_SELECT_MASS_PAYMENT = "//select[@id='fromAccount']/option[1]";
    String FROM_FIRST_OWN_ACCOUNT_SELECT = "//select[@id='CatFromAccount']/option[2]";
    String TO_ACCOUNT_NUMBER_INPUT = "//div[@id='document']//form[@id='mainFrm']//input[@name='partnerAccountNumber']";
    String TO_ACCOUNT_BANK_INPUT = "//div[@id='document']//form[@id='mainFrm']//input[@id='partnerAccountBank']";
    String TO_SECOND_OWN_ACCOUNT_SELECT = "//select[@id='CatToAccount']/option[3]";
    String AMOUNT_INPUT = "//div[@id='document']//form[@id='mainFrm']//input[@id='amount']";
    String VARIABLE_SYMBOL_INPUT = "//div[@id='document']//form[@id='mainFrm']//input[@id='vs']";
    String CONSTANT_SYMBOL_INPUT = "//div[@id='document']//form[@id='mainFrm']//input[@name='cs']";
    String NOTE_FOR_RECIPIENT_AREA = "//input[@id='avizo']";
    String NOTE_FOR_RECIPIENT_AREA_MASS_PAYMENT = "//textarea[@id='avizo']";
    String CATEGORY_SELECT = "//select[@id='categoryId']";
    String NOTE_AREA = "//input[@id='note']";
    String STANDARD_PAYMENT = "//input[@id='paymentTypeStandard']";
    String INSTANT_PAYMENT = "//input[@id='paymentTypeInstant']";
    String PRIORITY_PAYMENT = "//input[@id='paymentTypePriority']";
    String CONTINUE_BUTTON = "//a[@id='continueStep2']";
    String CONTINUE_BUTTON_MASS_PAYMENT = "//img[@id='continueStep2']";
    String ADD_PAYMENT_ORDER = "//img[@alt='Přidat příkaz k úhradě']";

    @Click(TRANSFER_BETWEEN_OWN_ACCOUNTS)
    PaymentOrderCreatePage clickTransferBetweenOwnAccounts();

    @Click(MASS_PAYMENT)
    PaymentOrderCreatePage clickMassPayment();

    @Click(FROM_ACCOUNT_SELECT)
    PaymentOrderCreatePage clickFromAccountSelect();

    @Click(value = FROM_ACCOUNT_SELECT_BY_NAME, isStringDynamicXpath = true)
    PaymentOrderCreatePage selectFromAccountByName(String nameAccount);

    @Click(FROM_FIRST_OWN_ACCOUNT_SELECT_MASS_PAYMENT)
    PaymentOrderCreatePage clickFromFirstAccountMassPaymentSelect();

    @Click(FROM_FIRST_OWN_ACCOUNT_SELECT)
    PaymentOrderCreatePage clickFromFirstAccountSelect();

    @TypeInto(TO_ACCOUNT_NUMBER_INPUT)
    PaymentOrderCreatePage fillToAccountNumber(String toAccountNumber);

    @TypeInto(TO_ACCOUNT_BANK_INPUT)
    PaymentOrderCreatePage fillToAccountBank(String toAccountBank);

    @Click(TO_SECOND_OWN_ACCOUNT_SELECT)
    PaymentOrderCreatePage clickToSecondOwnAccountSelect();

    @TypeInto(value = AMOUNT_INPUT, andWait = @Wait(explicitWaitSeconds = 2))
    PaymentOrderCreatePage fillAmount(String amount);

    @TypeInto(VARIABLE_SYMBOL_INPUT)
    PaymentOrderCreatePage fillVariableSymbol(String variableSymbol);

    @TypeInto(CONSTANT_SYMBOL_INPUT)
    PaymentOrderCreatePage fillConstantSymbol(String constantSymbol);

    @TypeInto(NOTE_FOR_RECIPIENT_AREA)
    PaymentOrderCreatePage fillNoteForRecipient(String noteForRecipient);

    @TypeInto(NOTE_FOR_RECIPIENT_AREA_MASS_PAYMENT)
    PaymentOrderCreatePage fillNoteForRecipientMassPayment(String noteForRecipient);

    @Wait(explicitWaitSeconds = 1)
    @Click(STANDARD_PAYMENT)
    PaymentOrderCreatePage clickStandardPayment();

    @Click(INSTANT_PAYMENT)
    PaymentOrderCreatePage clickInstantPayment();

    @Click(PRIORITY_PAYMENT)
    PaymentOrderCreatePage clickPriorityPayment();

    @Click(CATEGORY_SELECT)
    PaymentOrderCreatePage clickCategorySelect();

    @TypeInto(NOTE_AREA)
    PaymentOrderCreatePage fillNote(String note);

    @Click(CONTINUE_BUTTON)
    PaymentOrderCreatePage clickContinueButtonMassPayment();

    @Click(ADD_PAYMENT_ORDER)
    PaymentOrderCreatePage clickAddPaymentOrder();

    @Click(CONTINUE_BUTTON_MASS_PAYMENT)
    PaymentOrderAuthorizePage clickMassPaymentContinueButton();

    @Click(CONTINUE_BUTTON)
    @Page(PaymentOrderAuthorizePage.class)
    PaymentOrderAuthorizePage clickContinueButton();
}