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.CheckElementPresent;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.TypeInto;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.newib.payments.DirectDebitSummaryPage.*;

@Wait(value = {TITLE_SUMMARY_PAGE_XPATH, EDIT_BUTTON_XPATH, CONFIRM_BUTTON_XPATH}, waitSecondsForElement = 30)
public interface DirectDebitSummaryPage extends NewIbPageFlow<DirectDebitSummaryPage>, VerticalMainMenu, HorizontalMainMenu {
    String TITLE_SUMMARY_PAGE_XPATH = "//h1[text()='Souhrn']";
    String EDIT_BUTTON_XPATH = "//button[@data-testid='back']";
    String CONFIRM_BUTTON_XPATH = "//button[@data-testid='submit']";
    String MOBILE_KEY_INPUT_XPATH = "//label[@for='mobileKey']//following-sibling::div//input[@id='mobileKey']";
    String MOBILE_KEY_SEND_BTN_XPATH = "//button[@data-testid='secondFactorSend']";
    String FROM_ACCOUNT_XPATH = "//tr[.//th[normalize-space()='Z účtu']]//td//span[contains(text(), '%s')]";
    String TO_ACCOUNT_XPATH = "//tr[.//th[normalize-space()='Ve prospěch účtu']]//td//span[contains(text(), '%s')]";
    String NAME_DEBIT_LIMIT_XPATH = "//tr[.//th[normalize-space()='Název inkasa']]//td//span[contains(text(), '%s')]";
    String DIRECT_DEBIT_LIMIT_XPATH = "//tr[.//th[normalize-space()='Limit inkasa']]//td//div[contains(text(), '%s')]";
    String END_DATE_XPATH = "//tr[.//th[normalize-space()='Datum poslední platby']]//td//span[contains(text(), '%s')]";
    String FREQUENCY_DIRECT_DEBIT_DATE_XPATH = "//tr[.//th[normalize-space()='Frekvence čerpání']]//td//span[contains(text(), '%s')]";
    String DATE_OF_FIRST_PAYMENT_XPATH = "//tr[.//th[normalize-space()='Datum začátku']]//td//span[contains(text(), '%s')]";
    String BACK_XPATH = "//button[@data-testid='back']";

    @Click(CONFIRM_BUTTON_XPATH)
    DirectDebitSummaryPage clickOnConfirm();

    @TypeInto(MOBILE_KEY_INPUT_XPATH)
    DirectDebitSummaryPage setMobileKey(String mobileKey);

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    DirectDebitVictoryPage clickOnContinueMobileKey();

    @CheckElementPresent(value = FROM_ACCOUNT_XPATH, isStringDynamicXpath = true)
    DirectDebitSummaryPage checkPaymentFromAccount(String fromAccount);

    @CheckElementPresent(value = TO_ACCOUNT_XPATH, isStringDynamicXpath = true)
    DirectDebitSummaryPage checkPaymentToAccount(String toAccount);

    @CheckElementPresent(value = NAME_DEBIT_LIMIT_XPATH, isStringDynamicXpath = true)
    DirectDebitSummaryPage checkNameOfDirectDebit(String directDebitName);

    @CheckElementPresent(value = DIRECT_DEBIT_LIMIT_XPATH, isStringDynamicXpath = true)
    DirectDebitSummaryPage checkLimitOfDirectDebit(String limitOfDirectDebit);

    @CheckElementPresent(value = END_DATE_XPATH, isStringDynamicXpath = true)
    DirectDebitSummaryPage checkEndDateOfDirectDebit(String dateOfLastPayment);

    @CheckElementPresent(value = FREQUENCY_DIRECT_DEBIT_DATE_XPATH, isStringDynamicXpath = true)
    DirectDebitSummaryPage checkFrequencyOfDirectDebit(String frequencyOfPayments);

    @CheckElementPresent(value = DATE_OF_FIRST_PAYMENT_XPATH, isStringDynamicXpath = true)
    DirectDebitSummaryPage checkDateOfFirstPayment(String dateOfFirstPayment);

    @Click(BACK_XPATH)
    DirectDebitPage clickBack();
}
