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

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.*;

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

@Wait(value = {EDIT_BUTTON_XPATH, CONTINUE_BUTTON_XPATH, TITLE_SUMMARY_PAGE_XPATH}, waitSecondsForElement = 30)
public interface MobileOperatorsPaymentSummaryPage extends NewIbPageFlow<MobileOperatorsPaymentSummaryPage>, StoreAccessor, Builder {

    String TITLE_SUMMARY_PAGE_XPATH = "//h3[text()='Souhrn']";
    String CONTINUE_BUTTON_XPATH = "//button[@data-testid='submit']";
    String EDIT_BUTTON_XPATH = "//button[@data-testid='back']";

    // SUMMARY FORM DATA
    String FROM_ACCOUNT_XPATH = "//div[text()='Platba z účtu']/following-sibling::div//span[text()='%s']";
    String RECIPIENT_PHONE_NUMBER_XPATH = "//tr[.//th//span[normalize-space(text())='Dobíjené číslo']]//td//span[contains(text(), '%s')]";
    String MOBILE_OPERATOR_XPATH = "//tr[.//th//span[normalize-space(text())='Mobilní operátor']]//td//span[contains(text(), '%s')]";
    String AMOUNT_XPATH = "//tr[.//th//span[normalize-space(text())='Částka']]//td//*[contains(text(), '%s')]";
    String CATEGORY_XPATH = "//tr[.//th//span[normalize-space(text())='Kategorie']]//td//span[contains(text(), '%s')]";
    String RECIPIENT_MESSAGE_XPATH = "//tr[.//th//span[normalize-space(text())='Zpráva, která přijde na dobíjené číslo']]//td//*[contains(text(), '%s')]";
    String CONFIRMATION_PHONE_NUMBER_XPATH = "//tr[.//th//span[normalize-space(text())='Číslo, na které přijde potvrzení']]//td//span[contains(text(), '%s')]";
    String MOBILE_KEY_INPUT_XPATH = "//input[@id='mobileKey']";
    String MOBILE_KEY_SEND_BTN_XPATH = "//button[@data-testid='secondFactorSend']";

    @Click(CONTINUE_BUTTON_XPATH)
    MobileOperatorsPaymentSummaryPage clickOnContinue();

    @Click(EDIT_BUTTON_XPATH)
    MobileOperatorsPaymentSummaryPage clickOnEdit();

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

    @CheckElementPresent(value = RECIPIENT_PHONE_NUMBER_XPATH, isStringDynamicXpath = true)
    MobileOperatorsPaymentSummaryPage checkRecipientPhoneNumber(String recipientPhoneNumber);

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

    @CheckElementPresent(value = MOBILE_OPERATOR_XPATH, isStringDynamicXpath = true)
    MobileOperatorsPaymentSummaryPage checkMobileOperator(String mobileOperator);

    @CheckElementPresent(value = CATEGORY_XPATH, isStringDynamicXpath = true)
    MobileOperatorsPaymentSummaryPage checkCategory(String category);

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

    @CheckElementPresent(value = CONFIRMATION_PHONE_NUMBER_XPATH, isStringDynamicXpath = true)
    MobileOperatorsPaymentSummaryPage checkConfirmationPhoneNumber(String confirmationPhoneNumber);

    @TypeInto(MOBILE_KEY_INPUT_XPATH)
    MobileOperatorsPaymentSummaryPage fillMobileKey(String mobileKey);

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    MobileOperatorsPaymentVictoryPage clickOnContinueMobileKey();
}
