package cz.moneta.test.dsl.ufo.banka.pages.cards.credit;

import cz.moneta.test.dsl.ufo.operations.shared.SharedElements;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ufo.banka.pages.cards.credit.NKK001_S007_QuickCreditCardApplicantInfoPage.SAVE_BUTTON;

@Wait(SAVE_BUTTON)
@Wait(value = "//input[@name='NKK001_S007_E001' and not(ancestor::div[contains(@style, 'display: none;')])]", by = Lookup.XPATH)
public interface NKK001_S007_QuickCreditCardApplicantInfoPage extends WebFlow<NKK001_S007_QuickCreditCardApplicantInfoPage>, StoreAccessor {

    String PAGE_ID_XPATH = "//div[text()='NKK001_S007']";
    String NOT_CONDUCTED_BY_EXTERNAL_ADVISOR = "NKK001_S007_H001_1";
    String STATEMENT_DISTRIBUTION_BY_POST = "NKK001_S007_R009_1";
    String SAVE_BUTTON = "NKK001_S007_B002";

    @TypeInto(value = "NKK001_S007_E001", clear = true)
    NKK001_S007_QuickCreditCardApplicantInfoPage setDailyLimitForWithdraw(String limit);

    @TypeInto(value = "NKK001_S007_E003", clear = true)
    NKK001_S007_QuickCreditCardApplicantInfoPage setDailyLimitForPurchases(String limit);

    @TypeInto(value = "NKK001_S007_E033", clear = true)
    NKK001_S007_QuickCreditCardApplicantInfoPage setDailyLimitForOnlinePurchases(String limit);

    @TypeInto(value = "NKK001_S007_E009", clear = true)
    NKK001_S007_QuickCreditCardApplicantInfoPage setActivationPassword(String password);

    @Click("NKK001_S007_R005_%s")
    NKK001_S007_QuickCreditCardApplicantInfoPage selectRepaymentMethod(RepaymentMethod repaymentMethod);

    @Click("NKK001_S007_R009_%s")
    NKK001_S007_QuickCreditCardApplicantInfoPage selectStatementDistributionMethod(StatementDistributionMethod statementDistributionMethod);

    @Click("NKK001_S007_R001_%s")
    NKK001_S007_QuickCreditCardApplicantInfoPage selectPinDistributionMethod(PinDistributionMethod pinDistributionMethod);

    @CustomAction
    default NKK001_S007_QuickCreditCardApplicantInfoPage dismissPinChargeAlert() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.dismissAlert(10);
        return null;
    }

    @Click("NKK001_S007_R007_%s")
    NKK001_S007_QuickCreditCardApplicantInfoPage selectDebitAccountType(DebitAccountType debitAccountType);

    @Click("NKK001_S007_R003_%s")
    NKK001_S007_QuickCreditCardApplicantInfoPage selectCreateAccountForCard(NeedAccount needAccount);

    @Click("NKK001_S007_R010_%s")
    NKK001_S007_QuickCreditCardApplicantInfoPage selectGetInsurance(NeedInsurance needInsurance);

    @CustomAction
    default NKK001_S007_QuickCreditCardApplicantInfoPageTransitions dismissClientNotificationAlert() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> SAVE_BUTTON, Lookup.ID);
        endpoint.dismissAlert(10);
        return null;
    }

    @Click(value = STATEMENT_DISTRIBUTION_BY_POST, andWait = @Wait(value = SharedElements.LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    NKK001_S007_QuickCreditCardApplicantInfoPage clickDistributionByPost();

    @Click(NOT_CONDUCTED_BY_EXTERNAL_ADVISOR)
    NKK001_S007_QuickCreditCardApplicantInfoPage clickNotByExternalAdvisor();

    @Click(SAVE_BUTTON)
    NKK001_S007_QuickCreditCardApplicantInfoPageTransitions clickSaveButton();

}
