package cz.moneta.test.dsl.newib.payments;

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.components.HorizontalMainMenu;
import cz.moneta.test.dsl.newib.components.VerticalMainMenu;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.newib.payments.NewPaymentSummaryPage.TITLE_SUMMARY_PAGE_XPATH;

@Wait(value = {TITLE_SUMMARY_PAGE_XPATH}, waitSecondsForElement = 30)
public interface NewPaymentSummaryPage extends NewIbPageFlow<NewPaymentSummaryPage>, VerticalMainMenu, HorizontalMainMenu {
    String TITLE_SUMMARY_PAGE_XPATH = "//h1[@class='t-title t-title--h3'][text()='Souhrn']";
    String CONTINUE_BUTTON_XPATH = "//button[@data-testid='submit']";
    String CONTINUE_MOBILE_KEY_BUTTON_XPATH = "//button[@data-testid='secondFactorSend']";
    String MOBILE_KEY_INTO_XPATH = "//label[@for='mobileKey']//following-sibling::div//input[@id='mobileKey']";

    // Summary dates of form
    String FROM_ACCOUNT_XPATH = "//tr[.//span[text()='Z účtu']]//div[text()='%s']";
    String TO_ACCOUNT_XPATH = "//tr[.//span[text()='Na účet']]//span[text()='%s']";
    String AMOUNT_XPATH = "//tr[.//span[normalize-space(text())='Částka']]//div[contains(normalize-space(.), '%s')]";
    String TYPE_OF_PAYMENT_XPATH = "//th[.//span[text()='Typ platby']]/following-sibling::td//span[text()='%s']";
    String DATE_OF_PAYMENT_XPATH = "//th[.//span[text()='Datum splatnosti']]/following-sibling::td//span[normalize-space(text())='%s']";
    String VARIABLE_SYMBOL_XPATH = "//tr[.//span[text()='Variabilní symbol']]//span[text()='%s']";
    String CONSTANT_SYMBOL_XPATH = "//tr[.//span[text()='Konstantní symbol']]//span[text()='%s']";
    String SPECIFIC_SYMBOL_XPATH = "//tr[.//span[text()='Specifický symbol']]//span[text()='%s']";
    String MY_NOTE_XPATH = "//th[.//span[text()='Poznámka pro mě']]/following-sibling::td//div[normalize-space(text())='%s']";
    String RECIPIENT_MESSAGE_XPATH = "//tr[.//span[text()='Zpráva pro příjemce']]//div[text()='%s']";
    String BACK_XPATH = "//button[@data-testid='back']";
    String INDIVIDUAL_RATE_XPATH = "//span[@class='f-checkbox__over']";
    String CONTINUE_MOBILE_KEY_XPATH = "//button[@data-testid='secondFactorSend']";
    String OVER_LIMIT_ALERT_XPATH = "//p[.//small[contains(text(), 'Zadaná částka překračuje Váš %s limit pro platby')]]";
    String NO_MOBILE_KEY_NEEDED_INFORMATION_XPATH = "//div[@class='c-userAuth__title'][text()='Platbu mezi vlastními účty nemusíte potvrzovat.']";

    @CheckElementPresent(value = FROM_ACCOUNT_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkFromAccount(String fromAccount);

    @CheckElementPresent(value = TO_ACCOUNT_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkToAccount(String toAccount);

    @CheckElementPresent(value = AMOUNT_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkAmount(String amount);

    @CheckElementPresent(value = TYPE_OF_PAYMENT_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkTypeOfPayment(String typePayment);

    @CheckElementPresent(value = DATE_OF_PAYMENT_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkDateOfPayment(String date);

    @CheckElementPresent(value = VARIABLE_SYMBOL_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkVariableSymbol(String variableSymbol);

    @CheckElementPresent(value = CONSTANT_SYMBOL_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkConstantSymbol(String constantSymbol);

    @CheckElementPresent(value = SPECIFIC_SYMBOL_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkSpecificSymbol(String specificSymbol);

    @CheckElementPresent(value = RECIPIENT_MESSAGE_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkRecipientMessage(String recipientMessage);

    @CheckElementPresent(value = MY_NOTE_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkMyNote(String myNote);

    @Click(CONTINUE_BUTTON_XPATH)
    NewPaymentSummaryPage clickContinue();

    @TypeInto(MOBILE_KEY_INTO_XPATH)
    NewPaymentSummaryPage fillMobileKey(String mobileKey);

    @Click(CONTINUE_MOBILE_KEY_BUTTON_XPATH)
    PaymentOrderSentPage clickContinueMobileKey();

    @Click(value = BACK_XPATH, jsClick = true, andWait = @Wait(value = INDIVIDUAL_RATE_XPATH, until = Until.CLICKABLE))
    NewPaymentDomesticPage clickOnBack();

    @Click(CONTINUE_MOBILE_KEY_XPATH)
    NewForeignPaymentVictoryPage clickContinueButton();

    @CheckElementPresent(value = OVER_LIMIT_ALERT_XPATH, isStringDynamicXpath = true)
    NewPaymentSummaryPage checkAlertOverLimit(String category);

    @Click(CONTINUE_MOBILE_KEY_BUTTON_XPATH)
    NewPaymentSummarySwitchToStandardPage clickMobileKey();

    @CheckElementPresent(NO_MOBILE_KEY_NEEDED_INFORMATION_XPATH)
    NewPaymentSummaryPage checkNoMobileKeyIsNeeded();
}
