package cz.moneta.test.dsl.newib.settings.accounts;

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

@Wait(value = AccountsSettingsPage.BACK_TO_SETTINGS_XPATH, waitSecondsForElement = 30)
public interface AccountsSettingsPage extends NewIbPageFlow<AccountsSettingsPage> {
    String BACK_TO_SETTINGS_XPATH = "//button[@data-testid='back-to-settings-crossroad']";
    String ACCOUNT_XPATH = "//tr[@role='button' and contains(@class,'c-contentTableRow')]";
    String ACCOUNT_NAME_XPATH = "//span[@data-testid='item-info-customNameForFrontend']";
    String ACCOUNT_NUMBER_XPATH = "//span[@data-testid='item-info-accountNumber']";
    String ACCOUNT_IBAN_XPATH = "//span[@data-testid='item-info-iban']";
    String ACCOUNT_BIC_XPATH = "//span[@data-testid='item-info-bic']";
    String ACCOUNT_TYPE_XPATH = "//span[@data-testid='item-info-feePlanName']";
    String ACCOUNT_STATEMENT_FREQUENCY_XPATH = "//span[@data-testid='item-info-statementPeriod']";
    String ACCOUNT_STATEMENT_DISTRIBUTION_XPATH = "//span[@data-testid='item-info-statementDistributionType']";
    String NAME_BUTTON_XPATH = "//button[@data-testid='name-btn']";
    String CHANGE_NAME_INPUT_XPATH = "//input[@id='customName']";
    String SAVE_ACCOUNT_NAME_XPATH = "//button[@data-testid='save-account-name']";
    String CHANGE_STATEMENT_FREQUENCY_XPATH = "//button[@data-testid='statementPeriod-btn']";
    String CHANGE_STATEMENT_TITLE_XPATH = "//h2[@class='t-title t-title--h3 c-modal__title']";
    String BACK_BUTTON_XPATH = "//button[@data-testid='back-button']";
    String CHANGE_STATEMENT_DISTRIBUTION_XPATH = "//button[@data-testid='statementDistributionType-btn']";
    String SET_AS_PREFERRED_BTN_XPATH = "//button[@data-testid='account-set-as-preffered-button']";
    String CONFIRM_BUTTON_XPATH = "//button[@data-testid='confirm-button']";
    String SET_AS_PREFERRED_TITLE_XPATH = "//h2[normalize-space(text()) = 'Nastavili jste preferovaný účet.']";
    String PREFERRED_ACCOUNT_XPATH = "//div[normalize-space(text())='Preferovaný účet']";
    String CLOSE_ACCOUNT_BUTTON_XPATH = "//button[@data-testid='account-close']";
    String CLOSE_ACCOUNT_TITLE_XPATH = "//h1[contains(normalize-space(text()), 'Zrušení účtu')]";

    @Click(ACCOUNT_XPATH)
    AccountsSettingsPage clickOnAccount();

    @Wait(explicitWaitSeconds = 1)
    @CheckElementContent(value = ACCOUNT_NAME_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkAccountName(String accountName);

    @CheckElementContent(value = ACCOUNT_NUMBER_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkAccountNumber(String accountNumber);

    @CheckElementContent(value = ACCOUNT_IBAN_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkIban(String accountIban);

    @CheckElementContent(value = ACCOUNT_BIC_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkBic(String accountBic);

    @CheckElementContent(value = ACCOUNT_TYPE_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkAccountType(String accountType);

    @CheckElementContent(value = ACCOUNT_STATEMENT_FREQUENCY_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkStatementFrequency(String statementFrequency);

    @CheckElementContent(value = ACCOUNT_STATEMENT_DISTRIBUTION_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkStatementDistribution(String statementDistribution);

    @Wait(explicitWaitSeconds = 1)
    @Click(NAME_BUTTON_XPATH)
    AccountsSettingsPage clickOnChangeName();

    @TypeInto(CHANGE_NAME_INPUT_XPATH)
    AccountsSettingsPage typeIntoName(String newName);

    @Click(SAVE_ACCOUNT_NAME_XPATH)
    AccountsSettingsPage saveAccountName();

    @Click(CHANGE_STATEMENT_FREQUENCY_XPATH)
    AccountsSettingsPage clickOnChangeStatementFrequency();

    @CheckElementContent(value = CHANGE_STATEMENT_TITLE_XPATH, by = Lookup.XPATH)
    AccountsSettingsPage checkStatementTitle(String accountName);

    @Click(BACK_BUTTON_XPATH)
    AccountsSettingsPage clickOnBack();

    @Click(CHANGE_STATEMENT_DISTRIBUTION_XPATH)
    AccountsSettingsPage clickOnChangeStatementDistribution();

    @Click(SET_AS_PREFERRED_BTN_XPATH)
    AccountsSettingsPage clickOnSetAsPreferred();

    @Click(CONFIRM_BUTTON_XPATH)
    AccountsSettingsPage clickOnConfirm();

    @CheckElementPresent(SET_AS_PREFERRED_TITLE_XPATH)
    AccountsSettingsPage checkSetAsPreferredTitle();

    @CheckElementPresent(PREFERRED_ACCOUNT_XPATH)
    AccountsSettingsPage checkPreferredAccount();

    @Click(CLOSE_ACCOUNT_BUTTON_XPATH)
    AccountsSettingsPage clickOnCloseAccount();

    @CheckElementPresent(CLOSE_ACCOUNT_TITLE_XPATH)
    AccountsSettingsPage checkCloseAccountTitle();
}
