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

import cz.moneta.test.dsl.newib.NewIbPageFlow;
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.SipoOrderSummaryPage.*;

@Wait(value = {EDIT_BUTTON_XPATH, CONFIRM_BUTTON_XPATH}, waitSecondsForElement = 30)
public interface SipoOrderSummaryPage extends NewIbPageFlow<SipoOrderSummaryPage> {
    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[.//span[@data-testid='TextComponent' and text()='Z účtu'] and .//span[@data-testid='TextComponent' and text()='%s']]";
    String SIPO_NUMBER_XPATH = "//tr[.//span[@data-testid='TextComponent' and text()='Spojovací číslo'] and .//span[@data-testid='TextComponent' and contains(text(), '%s')]]";
    String SIPO_LIMIT_XPATH = "//tr[.//span[@data-testid='TextComponent' and text()='Limit SIPO'] and .//div[contains(@class, 't-amount') and contains(text(), '%s')]]";
    String END_MONTH_XPATH = "//tr[.//span[@data-testid='TextComponent' and text()='Měsíc konce odesílání'] and .//span[@data-testid='TextComponent' and contains(text(), '%s')]]";

    @Click(value = CONFIRM_BUTTON_XPATH, jsClick = true)
    SipoOrderSummaryPage clickOnConfirm();

    @Click(EDIT_BUTTON_XPATH)
    SipoOrderPage clickOnEdit();

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

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    SipoOrderVictoryPage clickOnContinueMobileKey();

    @CheckElementPresent(value = FROM_ACCOUNT_XPATH, isStringDynamicXpath = true)
    SipoOrderSummaryPage checkPaymentAccount(String fromAccount);

    @CheckElementPresent(value = SIPO_NUMBER_XPATH, isStringDynamicXpath = true)
    SipoOrderSummaryPage checkSipoNumber(String sipoNumber);

    @CheckElementPresent(value = SIPO_LIMIT_XPATH, isStringDynamicXpath = true)
    SipoOrderSummaryPage checkSipoLimit(String sipoLimit);

    @CheckElementPresent(value = END_MONTH_XPATH, isStringDynamicXpath = true)
    SipoOrderSummaryPage checkEndDate(String endDate);
}
