package cz.moneta.test.dsl.ufo.banka.pages.products.consolidation;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;
import cz.moneta.test.harness.support.web.WebFlow;

import static cz.moneta.test.dsl.ufo.banka.pages.products.consolidation.UDC004_S001_LoanConsolidationPreApprovedOptions.PAGE_ID;

@Wait(value = PAGE_ID)
public interface UDC004_S001_LoanConsolidationPreApprovedOptions extends WebFlow<UDC004_S001_LoanConsolidationPreApprovedOptions>, StoreAccessor {

    String PAGE_ID = "UDC004_S001_X001";
    String PRE_APPROVED_COMBINATIONS_RADIOBUTTON = "UDC004_S001_G001-0";
    String VARIANTS_PROPOSED_BUTTON = "UDC004_S001_B001";

    @Click(value = PRE_APPROVED_COMBINATIONS_RADIOBUTTON, andWait = @Wait(value = VARIANTS_PROPOSED_BUTTON, until = Until.VISIBLE))
    UDC004_S001_LoanConsolidationPreApprovedOptions clickPreApprovedCombinationsRadioButton();

    @Click(VARIANTS_PROPOSED_BUTTON)
    UDC004_S002_LoanConsolidationNonBindingOffer clickVariantsProposedButton();

    @CustomAction
    default UDC004_S002_LoanConsolidationNonBindingOffer clickPreApprovedCombinationAndVariantsProposedButton() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> PRE_APPROVED_COMBINATIONS_RADIOBUTTON);
        endpoint.waitForElementsToLoad(45, VARIANTS_PROPOSED_BUTTON);
        endpoint.click(() -> VARIANTS_PROPOSED_BUTTON);
        return null;
    }
}