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

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

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

@Wait(value = {TITLE_SUMMARY_PAGE_XPATH, ADD_PAYMENT_BTN_XPATH, CONTINUE_BTN_XPATH}, waitSecondsForElement = 30)
public interface BulkPaymentSummaryPage extends NewIbPageFlow<BulkPaymentSummaryPage> {

    String TITLE_SUMMARY_PAGE_XPATH = "//h1[@class='t-title t-title--h3 u-mb--xLarge'][text()='Souhrn']";
    String ADD_PAYMENT_BTN_XPATH = "//button[@data-testid='bulk-payment-add']";
    String CONTINUE_BTN_XPATH = "//button[@data-testid='bulk-payment-continue']";
    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 RECIPIENT_ACC_NUMBER_XPATH = "//p[@class='u-fontWeightBold u-m--0'][text()='%s']";
    String AMOUNT_XPATH = "//div[@class='t-amount t-amount--medium t-amount--bold'][starts-with(normalize-space(), '%s')]";
    String PAYMENTS_COUNT_AVATAR_XPATH = "//span[@class='c-avatar__text'][text()='%s']";
    String SUBMIT_XPATH = "//button[@data-testid='submit']";
    String OVER_LIMIT_PAYMENT_WARNING_TEXT_XPATH = "//p[@class='u-mb--0' and @data-testid='TextComponent']/small[normalize-space(text())='%s']";
    String BACK_XPATH = "//button[@data-testid='back']";
    String DELETE_PAYMENT_BTN_XPATH = "//button[@aria-label='Smazat' and @data-testid='delete-payment-3']";
    String CANCEL_MODAL_CLOSE_XPATH = "//button[@data-testid='cancel-modal-close']";
    String CANCEL_MODAL_CONFIRM_XPATH = "//button[@data-testid='cancel-modal-confirm']";
    String ACCOUNT_NUMBER_INPUT_XPATH = "//input[@id='destinationAccountNumber']";

    @Click(CONTINUE_BTN_XPATH)
    BulkPaymentSummaryPage clickOnContinue();

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

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    BulkPaymentVictoryPage clickOnContinueMobileKey();

    @CheckElementPresent(value = RECIPIENT_ACC_NUMBER_XPATH, isStringDynamicXpath = true)
    BulkPaymentSummaryPage checkRecipientAccNumber(String recipientAccNumber);

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

    @CheckElementPresent(value = PAYMENTS_COUNT_AVATAR_XPATH, isStringDynamicXpath = true)
    BulkPaymentSummaryPage checkNumberOfPayments(String numberOfPayments);

    @Click(value = ADD_PAYMENT_BTN_XPATH, andWait = @Wait(value = ACCOUNT_NUMBER_INPUT_XPATH, waitSecondsForElement = 10, until = Until.CLICKABLE))
    BulkPaymentPage clickOnAddPayment();

    @Click(SUBMIT_XPATH)
    BulkPaymentSummaryPage clickOnSubmit();

    @CheckElementPresent(value = OVER_LIMIT_PAYMENT_WARNING_TEXT_XPATH, isStringDynamicXpath = true)
    BulkPaymentSummaryPage checkOverLimitPaymentWarningText(String overLimitPaymentWarningText);

    @Click(BACK_XPATH)
    BulkPaymentSummaryPage clickOnBack();

    @Click(DELETE_PAYMENT_BTN_XPATH)
    BulkPaymentSummaryPage clickOnDeletePayment();

    @Click(CANCEL_MODAL_CLOSE_XPATH)
    BulkPaymentSummaryPage clickOnCancelModalClose();

    @Click(CANCEL_MODAL_CONFIRM_XPATH)
    BulkPaymentSummaryPage clickOnCancelModalConfirm();
}
