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_MortgagesPanel.SEND_BUTTON;
import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;

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

    String NAME_INPUT = "XCM701_S001_E001";
    String SURNAME_INPUT = "XCM701_S001_E002";
    String BIRTH_NUMBER_INPUT = "XCM701_S001_E029";
    String PHONE_INPUT = "XCM701_S001_E004";
    String EMAIL_INPUT = "XCM701_S001_E005";
    String NOTE_INPUT = "XCM701_S001_M003";
    String VILLAGE_INPUT = "XCM701_S001_E007";
    String CALENDAR_INPUT = "XCM701_S001_E008";
    String AVAILABILITY_TIME_HOUR_INPUT = "XCM701_S001_E069";
    String AVAILABILITY_TIME_MINUTE_INPUT = "XCM701_S001_E072";
    String CONTACT_SOURCE_SELECT = "XCM701_S001_C003";
    String AMOUNT_INPUT = "XCM701_S001_E006";
    String CONSENT_101_CHECKBOX = "XCM701_S001_H001_1";
    String SEND_BUTTON = "XCM701_S001_B001";

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

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

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

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

    @Select(CONTACT_SOURCE_SELECT)
    XCM701_S001_MortgagesPanel selectContactSource(String source);

    @TypeInto(AMOUNT_INPUT)
    XCM701_S001_MortgagesPanel fillAmount(String amount);

    @Click(CONSENT_101_CHECKBOX)
    @AcceptAlert(waitSecondsForAlert = 5, expectedAlertText = CONSENT_101_ALERT_TEXT)
    XCM701_S001_MortgagesPanel clickConsent101();

    @Click(value = SEND_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STS701_S002_ClientDetailPage clickSend();

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

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

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

    @CustomAction
    default XCM701_S001_MortgagesPanel checkPhone(String phone) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(phone, endpoint.getAttribute(PHONE_INPUT, "value"));
        return null;
    }

    @CustomAction
    default XCM701_S001_MortgagesPanel checkEmail(String email) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(email, endpoint.getAttribute(EMAIL_INPUT, "value"));
        return null;
    }

    @CustomAction
    default XCM701_S001_MortgagesPanel checkVillage(String village) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(village, endpoint.getAttribute(VILLAGE_INPUT, "value"));
        return null;
    }
}