package cz.moneta.test.dsl.ib.doidentifikace;

import cz.moneta.test.dsl.ib.IbPageFlow;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ib.IbEndpoint;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.TypeInto;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.ib.doidentifikace.IdentityCardPage.IDENTITY_CARD_WINDOW;

@Wait(IDENTITY_CARD_WINDOW)
public interface IdentityCardPage extends IbPageFlow<IdentityCardPage>, StoreAccessor {
    String IDENTITY_CARD_WINDOW = "//input[@testid='validity-input']";
    String CONFIRM_DATE_ID = "//button[@testid='verify-id-validity-button']";

    @CustomAction
    default IdentityCardPage focusAndClickToDateId() {
        IbEndpoint endpoint = getEndpoint(IbEndpoint.class);
        endpoint.moveToElement(IDENTITY_CARD_WINDOW);
        endpoint.click(() -> IDENTITY_CARD_WINDOW);
        return null;
    }

    @TypeInto(value = IDENTITY_CARD_WINDOW, clear = true)
    IdentityCardPage typeDateId(String dateID);

    @CustomAction
    default PhoneNumberPage focusAndClickToDateConfirm() {
        IbEndpoint endpoint = getEndpoint(IbEndpoint.class);
        endpoint.moveToElement(IDENTITY_CARD_WINDOW);
        endpoint.click(() -> CONFIRM_DATE_ID);
        return null;
    }
}