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

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

    String CAMPAIGN_NAME_SELECT = "XCM701_S001_C015";
    String BIRTH_NUMBER_INPUT = "XCM701_S001_E058";
    String NAME_INPUT = "XCM701_S001_E060";
    String SURNAME_INPUT = "XCM701_S001_E061";
    String MOBILE_INPUT = "XCM701_S001_E063";
    String EMAIL_INPUT = "XCM701_S001_E065";
    String VILLAGE_INPUT = "XCM701_S001_E068";
    String NOTE_INPUT = "XCM701_S001_M010";
    String AVAILABILITY_TIME_HOUR_INPUT = "XCM701_S001_E049";
    String AVAILABILITY_TIME_MINUTE_INPUT = "XCM701_S001_E047";
    String SOURCE_OF_CONTACT_SELECT = "XCM701_S001_C020";
    String PRODUCT_TO_CANCEL_SELECT = "XCM701_S001_C021";
    String TYPE_OF_WRITTEN_REQUEST_SELECT = "XCM701_S001_C019";
    String REASON_OF_HANDOVER_SELECT = "XCM701_S001_C022";
    String INTEREST_OF_SELECT = "XCM701_S001_C023";
    String CONSENT_101_CHECKBOX = "XCM701_S001_H011_1";
    String SEND_SMS_AND_DOCUMENTS_CHECKBOX = "XCM701_S001_H009_1";
    String SEND_BUTTON = "XCM701_S001_B010";

    @Select(value = CAMPAIGN_NAME_SELECT, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    XCM701_S001_OtherPanel selectNameOfCampaign(String name);

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

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

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

    @Select(SOURCE_OF_CONTACT_SELECT)
    XCM701_S001_OtherPanel selectSourceOfContact(String source);

    @Select(PRODUCT_TO_CANCEL_SELECT)
    XCM701_S001_OtherPanel selectProductToCancel(String product);

    @Select(TYPE_OF_WRITTEN_REQUEST_SELECT)
    XCM701_S001_OtherPanel selectTypeOfWrittenRequest(String type);

    @Select(REASON_OF_HANDOVER_SELECT)
    XCM701_S001_OtherPanel selectReasonOfHandover(String reason);

    @Select(INTEREST_OF_SELECT)
    XCM701_S001_OtherPanel selectInterestOf(String interest);

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

    @Click(SEND_SMS_AND_DOCUMENTS_CHECKBOX)
    XCM701_S001_OtherPanel clickSendSmsAndDocumentations();

    @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_OtherPanel checkBirthNumber(String number) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.waitForElementsToLoad(5, Until.VISIBLE, BIRTH_NUMBER_INPUT);
        Assertions.assertEquals(number, endpoint.getAttribute(BIRTH_NUMBER_INPUT, "value"));
        return null;
    }

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

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

    @CustomAction
    default XCM701_S001_OtherPanel checkMobile(String mobile) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(mobile, endpoint.getAttribute(MOBILE_INPUT, "value"));
        return null;
    }

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

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