package cz.moneta.test.dsl.ufo.operations.ufoOperations.contactForwarding.panels;

import cz.moneta.test.dsl.ufo.operations.client.clientDetail.STS701_S002_ClientDetailPage;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.contactForwarding.XCM701_S001_ContactForwardingPage;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;
import org.junit.jupiter.api.Assertions;

import static cz.moneta.test.dsl.ufo.operations.ufoOperations.contactForwarding.panels.XCM701_S001_SellPanel.SEND_BUTTON;

@Wait(value = SEND_BUTTON, until = Until.VISIBLE)
public interface XCM701_S001_SellPanel extends XCM701_S001_ContactForwardingPage {

    String NAME_INPUT = "XCM701_S001_E054";
    String SURNAME_INPUT = "XCM701_S001_E055";
    String BIRTH_NUMBER_INPUT = "XCM701_S001_E079";
    String CALENDAR_INPUT = "XCM701_S001_E034";
    String AVAILABILITY_TIME_HOUR_INPUT = "XCM701_S001_E044";
    String AVAILABILITY_TIME_MINUTE_INPUT = "XCM701_S001_E043";
    String TELEPHONE_INPUT = "XCM701_S001_E036";
    String NOTE_INPUT = "XCM701_S001_M008";
    String SEND_BUTTON = "XCM701_S001_B003";

    @TypeInto(CALENDAR_INPUT)
    XCM701_S001_SellPanel fillDate(String date);

    @TypeInto(AVAILABILITY_TIME_HOUR_INPUT)
    XCM701_S001_SellPanel fillAvailabilityTimeHour(String hour);

    @TypeInto(AVAILABILITY_TIME_MINUTE_INPUT)
    XCM701_S001_SellPanel fillAvailabilityTimeMinute(String minute);

    @TypeInto(value = TELEPHONE_INPUT, clear = true)
    XCM701_S001_SellPanel fillTelephone(String telephone);

    @TypeInto(NOTE_INPUT)
    XCM701_S001_SellPanel fillNote(String note);

    @Click(SEND_BUTTON)
    STS701_S002_ClientDetailPage clickSend();

    @CustomAction
    default XCM701_S001_SellPanel checkName(String name) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(name, endpoint.getAttribute(NAME_INPUT, "value"));
        return null;
    }

    @CustomAction
    default XCM701_S001_SellPanel checkSurname(String surname) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(surname, endpoint.getAttribute(SURNAME_INPUT, "value"));
        return null;
    }

    @CustomAction
    default XCM701_S001_SellPanel checkBirthNumber(String birthNumber) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(birthNumber, endpoint.getAttribute(BIRTH_NUMBER_INPUT, "value"));
        return null;
    }
}