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

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.foreign.ForeignPaymentOderCreatePage.CONTINUE_BUTTON;
import static cz.moneta.test.dsl.ib.payment.foreign.ForeignPaymentOderCreatePage.FROM_ACCOUNT_SELECT;


@Wait({FROM_ACCOUNT_SELECT, CONTINUE_BUTTON})
public interface ForeignPaymentOderCreatePage extends IbPageFlow<ForeignPaymentOderCreatePage>, MainMenu, AccountsAndTransactionsSubmenu {

    String SEPA_PAYMENT_SELECT = "//input[@value='FPOE']";
    String FOREIGN_CURRENCY_ORDER_BETWEEN_OWN_ACCOUNTS = "//input[@value='FPOK']";
    String FOREIGN_CURRENCY_ORDER_BETWEEN_MMB_ACCOUNTS = "//input[@value='FPOT2']";
    String PARENT_ELEMENT_FORM =  "//div[@id='document']//form[@id='mainFrm']";
    String FROM_ACCOUNT_SELECT = PARENT_ELEMENT_FORM + "//select[@id='fromAccount']";
    String FROM_FIRST_ACCOUNT_SELECT = "//select[@id='fromAccount']/option[2]";
    String TO_OWN_SECOND_ACCOUNT_SELECT = "//select[@id='fpo.toAccount']/option[3]";
    String AMOUNT_INPUT = PARENT_ELEMENT_FORM +  "//input[@id='castka']";
    String TO_ACCOUNT_CURRENCY_INPUT = PARENT_ELEMENT_FORM + "//select[@id='mena']";
    String CHARGE_SELECT = PARENT_ELEMENT_FORM + "//select[@id='vylohy']";
    String TO_ACCOUNT_NUMBER_INPUT = PARENT_ELEMENT_FORM + "//input[@name='partnerAccountNumber2']";
    String TO_SEPA_ACCOUNT_NUMBER_INPUT = PARENT_ELEMENT_FORM + "//input[@name='partnerAccountNumber5']";
    String TO_MMB_ACCOUNT_NUMBER_INPUT = PARENT_ELEMENT_FORM + "//input[@name='partnerAccountNumberFPOT2']";
    String RECIPIENT_NAME_INPUT = PARENT_ELEMENT_FORM + "//input[@name='prijemce']";
    String RECIPIENT_ADDRESS_INPUT = PARENT_ELEMENT_FORM + "//input[@name='prijemceJmeno']";
    String RECIPIENT_CITY_INPUT = PARENT_ELEMENT_FORM + "//input[@name='prijemceStat']";
    String NOTE_AREA = PARENT_ELEMENT_FORM + "//textarea[@id='fpo.avizo']";
    String CHECK_RECIPIENTS_ACCOUNT = "//img[@alt='Ověřit účet příjemce']";
    String CONTINUE_BUTTON = PARENT_ELEMENT_FORM + "//img[contains(@src, 'pokracovat_b.gif')]";
    String LOADER_DIV = "//div[@class='busyLoader' and @style='display: block;']";

    @Click(SEPA_PAYMENT_SELECT)
    ForeignPaymentOderCreatePage clickSEPAPayment();

    @Click(FOREIGN_CURRENCY_ORDER_BETWEEN_OWN_ACCOUNTS)
    ForeignPaymentOderCreatePage clickForeignPaymentBetweenOwnPayment();

    @Click(FOREIGN_CURRENCY_ORDER_BETWEEN_MMB_ACCOUNTS)
    ForeignPaymentOderCreatePage clickForeignPaymentBetweenMMBAccountsPayment();

    @Click(FROM_ACCOUNT_SELECT)
    ForeignPaymentOderCreatePage clickFromAccountSelect();

    @Click(FROM_FIRST_ACCOUNT_SELECT)
    ForeignPaymentOderCreatePage clickFromFirstAccountSelect();

    @Click(TO_OWN_SECOND_ACCOUNT_SELECT)
    ForeignPaymentOderCreatePage clickToOwnSecondAccountSelect();

    @TypeInto(AMOUNT_INPUT)
    ForeignPaymentOderCreatePage fillAmount(String amount);

    @Select(TO_ACCOUNT_CURRENCY_INPUT)
    ForeignPaymentOderCreatePage clickCurrencySelect(String currency);

    @Select(CHARGE_SELECT)
    ForeignPaymentOderCreatePage clickChargeSelect(String charge);

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

    @TypeInto(TO_SEPA_ACCOUNT_NUMBER_INPUT)
    ForeignPaymentOderCreatePage fillToSEPAAccountNumber(String toAccountNumber);

    @TypeInto(TO_MMB_ACCOUNT_NUMBER_INPUT)
    ForeignPaymentOderCreatePage fillToMMBAccountNumber(String toAccountNumber);

    @TypeInto(RECIPIENT_NAME_INPUT)
    ForeignPaymentOderCreatePage fillRecipientName(String recipientName);

    @TypeInto(RECIPIENT_ADDRESS_INPUT)
    ForeignPaymentOderCreatePage fillRecipientAddress(String recipientAddress);

    @TypeInto(RECIPIENT_CITY_INPUT)
    ForeignPaymentOderCreatePage fillRecipientCity(String recipientCity);

    @TypeInto(NOTE_AREA)
    ForeignPaymentOderCreatePage fillNote(String recipientBankName);

    @Click(value = CHECK_RECIPIENTS_ACCOUNT, andWait = @Wait(value = LOADER_DIV, until = Until.GONE))
    ForeignPaymentOderCreatePage clickCheckRecipientsAccButton();

    @Click(CONTINUE_BUTTON)
    ForeignPaymentOrderAuthorizePage clickContinueButton();
}

