package cz.moneta.test.dsl.ufo.operations.client;

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.operations.client.ClientRiskDetails.AP_LIST_TABLE;

@Wait({AP_LIST_TABLE})
public interface ClientRiskDetails extends StoreAccessor, WebFlow<ClientRiskDetails> {

    String AP_LIST_TABLE = "SCH707_S001_G001_UfoTable";
    String AP_LIST_TABLE_XPATH = "//table [@id='" + AP_LIST_TABLE + "']";
    String ERROR_BUTTON = "SCH707_S001_B009";
    String APPROVAL_DATA_BUTTON = "SCH707_S001_B013";
    String AP_REQUIREMENT_NUMBER_INPUT = AP_LIST_TABLE_XPATH + "//input[@value='%s']";

    @CustomAction
    default ClientRiskDetails clickAP(String AP) {
        String xpath = String.format(AP_REQUIREMENT_NUMBER_INPUT, AP);
        getEndpoint(UfoEndpoint.class).click(() -> xpath, Lookup.XPATH);
        return null;
    }

    @Click(ERROR_BUTTON)
    ClientRiskDetails clickErrorButton();

    @Click(APPROVAL_DATA_BUTTON)
    ScoringDataPage clickApprovalDataButton();

}
