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

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.mainpage.DashboardPage;
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.savings.RtvServicingPage.RTV_SERVICING_TITLE_XPATH;

@Wait(value = {RTV_SERVICING_TITLE_XPATH}, waitSecondsForElement = 30)
public interface RtvServicingPage extends NewIbPageFlow<RtvServicingPage> {

    String RTV_SERVICING_TITLE_XPATH = "//h1[@class='t-title t-title--h3 u-mb--xxLarge' and contains(text(), 'termínovaný vklad')]";
    String RTV_DEPOSIT_TITLE_XPATH = "//h1[@class='t-title t-title--h3 u-mb--xxLarge' and text()='Vklad na revolvingový termínovaný vklad']";
    String RTV_DEPOSIT_SOURCE_ACCOUNT_LABEL_XPATH = "//label[@id='sourceAccountId_label' and text()='Vložit z účtu']";
    String RTV_DEPOSIT_SOURCE_ACCOUNT_NUMBER_XPATH = "//button[@id='sourceAccountId_button' and @data-value='%s'][not(@disabled)]";
    String RTV_DEPOSIT_TEMPLATE_LABEL_XPATH = "//label[@id='template_label' and text()='Na účet']";
    String RTV_DESTINATION_ACCOUNT_PREFIX_LABEL_XPATH = "//label[@id='destinationAccountPrefix_label' and text()='Předčíslí']";
    String RTV_DESTINATION_ACCOUNT_NUMBER_LABEL_XPATH = "//label[@id='destinationAccountNumber_label' and text()='Číslo účtu']";
    String RTV_DESTINATION_ACCOUNT_BANK_LABEL_XPATH = "//label[@id='destinationAccountBank_label' and text()='Kód banky']";
    String RTV_DEPOSIT_AMOUNT_LABEL_XPATH = "//label[@id='amount_label' and text()='Částka']";
    String RTV_DEPOSIT_TEXT_XPATH = "//p[@data-testid='TextComponent']//small[normalize-space(.)='Aby vklad proběhl, mějte poslední pracovní den před dnem obnovy do 20:00 dostatečný zůstatek na účtu.']";
    String RTV_DUE_DATE_LABEL_XPATH = "//label[@id='dueDate_label' and text()='Datum splatnosti']";
    String RTV_DUE_DATE_FIELD_DISABLED_XPATH = "//input[@aria-labelledby='dueDate_label'][@disabled]";
    String RTV_CHANGE_TO_OTHER_DATE_XPATH  = "//p[@data-testid='TextComponent']//small[normalize-space(.)='Změna k jinému datu než ke dni obnovy je zpoplatněna. Požádat o ni můžete na našich pobočkách nebo písemně (žádost musí být doručena před dnem obnovy).']";
    String RTV_DEPOSIT_AMOUNT_FIELD_XPATH = "//input[@id='amount']";
    String RTV_DEPOSIT_DESTINATION_ACCOUNT_NUMBER_XPATH = "//input[@data-testid='destinationAccountNumber' and @value='%s'][@disabled]";
    String RTV_SERVICING_CONTINUE_BUTTON_XPATH = "//button[@data-testid='rtv-deposit--continue' and text()='Pokračovat']";
    String RTV_SERVICING_CONTRACT_TITLE_XPATH = "//h2[@class='t-title t-title--h4' and text()='Prosím zkontrolujte dokument se změnami podle vašich požadavků']";
    String RTV_SERVICING_SIGN_BUTTON_XPATH = "//button[@data-testid='btn-contract-confirm' and text()='Podepsat']";
    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 RTV_SERVICING_VICTORY_TEXT_XPATH = "//div[@data-testid='rtv-servicing-victory'][contains(., 'Přijali jsme vaši žádost') and contains(., 'Uskutečníme ji v den obnovy') and contains(., 'a najdete ji už teď v sekci Dokumenty.') and contains(., 'Pokud chcete žádost zrušit') and contains(., ', můžete to udělat nejpozději poslední pracovní den před dnem obnovy do 20:00 v detailu produktu.')]";
    String BACK_TO_DASHBOARD_BUTTON_XPATH = "//button[@data-testid='btn-primary-button' and text()='Zpět na Přehled']";
    String RTV_STORNO_TITLE_XPATH = "//h2[@class='t-title t-title--h4' and text()='Prosím zkontrolujte žádost o zrušení změn']";
    String RTV_STORNO_VICTORY_TEXT_XPATH = "//h3[normalize-space()='Hotovo!']/following-sibling::p[contains(., 'Vše, co bylo třeba, jsme podle vašeho přání zrušili. Žádost o zrušení najdete v sekci Dokumenty.')]";
    String RTV_WITHDRAWAL_SOURCE_ACCOUNT_LABEL_XPATH = "//label[@id='sourceAccountId_label' and text()='Výběr z účtu']";
    String RTV_WITHDRAWAL_SOURCE_ACCOUNT_NUMBER_XPATH = "//button[@id='sourceAccountId_button' and @data-value='%s'][@disabled]";
    String RTV_WITHDRAWAL_TITLE_XPATH = "//h1[@class='t-title t-title--h3 u-mb--xxLarge' and text()='Vybrat z účtu revolvingový termínovaný vklad']";
    String RTV_WITHDRAWAL_TEMPLATE_LABEL_XPATH = "//label[@id='template_label' and text()='Připsat na účet']";
    String RTV_WITHDRAWAL_AMOUNT_LABEL_XPATH = "//label[@id='rawAmount_label' and text()='Částka']";
    String RTV_WITHDRAWAL_AMOUNT_FIELD_XPATH = "//input[@id='rawAmount']";
    String RTV_CANCEL_TITLE_XPATH = "//h1[@class='t-title t-title--h3 u-mb--xxLarge' and text()='Vybrat vše a zrušit revolvingový termínovaný vklad']";
    String RTV_CANCEL_AMOUNT_FIELD_XPATH = "//input[@data-testid='rtv-amount' and @value='1 000 000'][@disabled]";
    String RTV_SERVICING_CANCEL_CONTINUE_BUTTON_XPATH = "//button[@data-testid='rtv-deposit--continue' and text()='Vybrat vše a zrušit účet']";
    String RTV_SERVICING_STORNO_BUTTON_ON_VICTORY = "//button[@data-testid='rtv-cancel-action-link' and text()='zrušit']";


    @CheckElementPresent(RTV_DEPOSIT_TITLE_XPATH)
    RtvServicingPage checkRtvDepositTitle();

    @CheckElementPresent(RTV_DEPOSIT_SOURCE_ACCOUNT_LABEL_XPATH)
    RtvServicingPage checkRtvDepositSourceAccountLabel();

    @CheckElementPresent(RTV_DEPOSIT_TEMPLATE_LABEL_XPATH)
    RtvServicingPage checkRtvDepositTemplateLabel();

    @CheckElementPresent(RTV_DESTINATION_ACCOUNT_PREFIX_LABEL_XPATH)
    RtvServicingPage checkRtvDestinationAccountPrefixLabel();

    @CheckElementPresent(RTV_DESTINATION_ACCOUNT_NUMBER_LABEL_XPATH)
    RtvServicingPage checkRtvDestinationAccountNumberLabel();

    @CheckElementPresent(RTV_DESTINATION_ACCOUNT_BANK_LABEL_XPATH)
    RtvServicingPage checkRtvDestinationAccountBankLabel();

    @CheckElementPresent(RTV_DEPOSIT_AMOUNT_LABEL_XPATH)
    RtvServicingPage checkRtvDepositAmountLabel();

    @CheckElementPresent(RTV_DEPOSIT_TEXT_XPATH)
    RtvServicingPage checkRtvDepositText();

    @CheckElementPresent(RTV_DUE_DATE_LABEL_XPATH)
    RtvServicingPage checkRtvDueDateLabel();

    @CheckElementPresent(RTV_DUE_DATE_FIELD_DISABLED_XPATH)
    RtvServicingPage checkRtvDueDateFieldDisabled();

    @CheckElementPresent(RTV_CHANGE_TO_OTHER_DATE_XPATH)
    RtvServicingPage checkRtvChangeToOtherDate();

    @TypeInto(value = RTV_DEPOSIT_AMOUNT_FIELD_XPATH)
    RtvServicingPage fillDepositAmount(String amount);

    @Click(RTV_SERVICING_CONTINUE_BUTTON_XPATH)
    RtvServicingPage clickOnContinue();

    @CheckElementPresent(RTV_SERVICING_CONTRACT_TITLE_XPATH)
    RtvServicingPage checkRtvServicingContractTitle();

    @Click(RTV_SERVICING_SIGN_BUTTON_XPATH)
    RtvServicingPage clickOnSignButton();

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

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    RtvServicingPage clickOnContinueMobileKey();

    @CheckElementPresent(RTV_SERVICING_VICTORY_TEXT_XPATH)
    RtvServicingPage checkRtvServicingVictoryText();

    @Click(BACK_TO_DASHBOARD_BUTTON_XPATH)
    DashboardPage clickBackToDashboard();

    @CheckElementPresent(RTV_STORNO_TITLE_XPATH)
    RtvServicingPage checkRtvStornoTitle();

    @CheckElementPresent(RTV_STORNO_VICTORY_TEXT_XPATH)
    RtvServicingPage checkRtvStornoVictoryText();

    @CheckElementPresent(value = RTV_DEPOSIT_DESTINATION_ACCOUNT_NUMBER_XPATH, isStringDynamicXpath = true)
    RtvServicingPage checkRtvDepositDestinationAccountNumber(String account);

    @CheckElementPresent(value = RTV_DEPOSIT_SOURCE_ACCOUNT_NUMBER_XPATH, isStringDynamicXpath = true)
    RtvServicingPage checkRtvSourceAccountNumberDeposit(String account);

    @CheckElementPresent(RTV_WITHDRAWAL_SOURCE_ACCOUNT_LABEL_XPATH)
    RtvServicingPage checkRtvWithdrawalSourceAccountLabel();

    @CheckElementPresent(RTV_WITHDRAWAL_TITLE_XPATH)
    RtvServicingPage checkRtvWithdrawalTitle();

    @CheckElementPresent(value = RTV_WITHDRAWAL_SOURCE_ACCOUNT_NUMBER_XPATH, isStringDynamicXpath = true)
    RtvServicingPage checkRtvSourceAccountNumberWithdrawal(String account);

    @CheckElementPresent(RTV_WITHDRAWAL_TEMPLATE_LABEL_XPATH)
    RtvServicingPage checkRtvWithdrawalTemplateLabel();

    @CheckElementPresent(RTV_WITHDRAWAL_AMOUNT_LABEL_XPATH)
    RtvServicingPage checkRtvWithdrawalAmountLabel();

    @TypeInto(value = RTV_WITHDRAWAL_AMOUNT_FIELD_XPATH)
    RtvServicingPage fillWithdrawalAmount(String amount);

    @CheckElementPresent(RTV_CANCEL_TITLE_XPATH)
    RtvServicingPage checkRtvCancelTitle();

    @CheckElementPresent(RTV_CANCEL_AMOUNT_FIELD_XPATH)
    RtvServicingPage checkRtvCancelAmount();

    @Click(RTV_SERVICING_CANCEL_CONTINUE_BUTTON_XPATH)
    RtvServicingPage clickOnContinueRtvServicingCancelButton();

    @Click(RTV_SERVICING_STORNO_BUTTON_ON_VICTORY)
    RtvServicingPage clickOnRtvServicingStornoButtonOnVictory();
}