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

import cz.moneta.test.dsl.ufo.banka.pages.loans.NEP028_S001_SignaturePage;
import cz.moneta.test.dsl.ufo.banka.pages.main.signature.patterns.NPV010_S001_PrintSignPadPage;
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.UDC005_S001_LoanConsolidationScoringCommitmentsPage.PAGE_ID;

@Wait(value = {PAGE_ID}, waitSecondsForElement = 30)
public interface UDC005_S001_LoanConsolidationScoringCommitmentsPage extends WebFlow<UDC005_S001_LoanConsolidationScoringCommitmentsPage>, StoreAccessor {
    String PAGE_ID = "UDC005_S001_X001";
    String COMMITMENTS_TO_CONSOLIDATION_RADIOBUTTON = "UDC005_S001_G001-0";
    String EDIT_BUTTON = "UDC005_S001_B001";
    String CONTINUE_BUTTON = "UDC005_S001_B002";

    @Click(value = COMMITMENTS_TO_CONSOLIDATION_RADIOBUTTON, andWait = @Wait(value = EDIT_BUTTON, until = Until.VISIBLE))
    UDC005_S001_LoanConsolidationScoringCommitmentsPage clickCommitmentsToConsolidationRadioBtn();

    @Click(EDIT_BUTTON)
    UDC005_S002_CommitmentEditingPage clickEditButton();

    @Click(CONTINUE_BUTTON)
    NPV010_S001_PrintSignPadPage clickContinueToSignActionPage();

    @Click(CONTINUE_BUTTON)
    NEP028_S001_SignaturePage clickContinueToSignaturePage();

    @CustomAction
    default UDC005_S002_CommitmentEditingPage clickRadioButtonAndEditButton() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> COMMITMENTS_TO_CONSOLIDATION_RADIOBUTTON);
        endpoint.waitForElementsToLoad(45, EDIT_BUTTON);
        endpoint.click(() -> EDIT_BUTTON);
        return null;
    }
}