package cz.moneta.test.dsl.cashman.pages.menu_OM;

import cz.moneta.test.dsl.cashman.pages.CashmanHomePage;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.cashman.pages.menu_OM.CashmanOMNewOrderPage.OM_DROPDOWN;

@Wait(OM_DROPDOWN)
public interface CashmanOMNewOrderPage extends WebFlow<CashmanOMNewOrderPage> {
    String OM_DROPDOWN = "//button[@class='btn dropdown-toggle bs-placeholder btn-light']";
    String OM_3693 = "//a[@id='bs-select-2-103']";
    String CREATE_BUTTON = "//button[@id='confirm-send-order-to-ca-button-id']";
    String REQUIRED_DATE_INPUT = "//input[@id='requiredDate']";
    String NOTE_TEXTAREA = "//textarea[@id='note']";
    String BILLS_FLAG_CHECKBOX = "//input[@id='billsFlag']";
    String LOANS_REGISTRATION_NUMBERS_TEXTAREA = "//textarea[@id='loansRegistrationNumbers']";
    String NOMINAL_100_INPUT = "//input[@nominalid='trueNOTECZK100']";
    String NOMINAL_10_INPUT = "//input[@nominalid='trueCOINCZK10']";
    String BANKNOTES_SUMMARY = "(//span[@class='currency-list-no-break'])[14][contains(text(),'%s')]";
    String COINS_SUMMARY = "(//span[@class='currency-list-no-break'])[16][contains(text(),'%s')]";
    String SUMMARY = "(//span[@class='currency-list-no-break'])[18][contains(text(),'%s')]";
    String SEND = "//button[@class='btn btn-content confirm-btn btn-confirm']";
    String ORDER_ID_XPATH = "//div[@class='portlet-msg-success']/span";
    String ORDER_ID_KEY = "ORDER_ID_KEY";
    String HOME_PAGE = "//a[@href='/domu']";

    @Click(OM_DROPDOWN)
    @Click(OM_3693)
    CashmanOMNewOrderPage selectOM3693();

    @Click(CREATE_BUTTON)
    CashmanOMNewOrderPage createNewOrder();

    @TypeInto(REQUIRED_DATE_INPUT)
    @KeyPress(Key.ENTER)
    CashmanOMNewOrderPage fillRequiredDate(String date);

    @TypeInto(NOTE_TEXTAREA)
    CashmanOMNewOrderPage fillNote(String note);

    @Click(BILLS_FLAG_CHECKBOX)
    CashmanOMNewOrderPage clickOnBillsFlagCheckBox();

    @TypeInto(LOANS_REGISTRATION_NUMBERS_TEXTAREA)
    CashmanOMNewOrderPage fillLoansRegistrationNumbers(String loansRegistrationNumbers);

    @TypeInto(value = NOMINAL_100_INPUT, clear = true)
    CashmanOMNewOrderPage fillNominal100Amount(String amountBanknotes);

    @TypeInto(value = NOMINAL_10_INPUT, clear = true)
    CashmanOMNewOrderPage fillNominal10Amount(String amountCoins);

    @CheckElementPresent(value = BANKNOTES_SUMMARY, isStringDynamicXpath = true)
    CashmanOMNewOrderPage checkBanknotesSummary(String banknotesSummary);

    @CheckElementPresent(value = COINS_SUMMARY, isStringDynamicXpath = true)
    CashmanOMNewOrderPage checkCoinsSummary(String coinsSummary);

    @CheckElementPresent(value = SUMMARY, isStringDynamicXpath = true)
    CashmanOMNewOrderPage checkSummary(String summary);

    @KeyPress(Key.ENTER)
    CashmanOMNewOrderPage submitNewOrder();

    @Click(value = SEND, andWait = @Wait(value = ORDER_ID_XPATH, until = Until.VISIBLE))
    CashmanOMNewOrderPage sendNewOrder();

    @StoreElementContent(storeKey = ORDER_ID_KEY, value = ORDER_ID_XPATH)
    CashmanOMNewOrderPage storeOrderId();

    @Click(HOME_PAGE)
    CashmanHomePage clickOnHomePage();
}
