package cz.moneta.test.dsl.ufo.operations.ufoOperations.sendingInformationsToClient;

import cz.moneta.test.dsl.ufo.operations.ufoOperations.HUS701_S001_WarningPage;
import cz.moneta.test.harness.context.StoreAccessor;
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;

public interface STI701_S002_EmailPanel extends StoreAccessor, WebFlow<STI701_S002_EmailPanel> {

    String SENDING_FINAL_STATEMENT_RADIO = "ufo-et-STI701_S002_F002_row_5_sel";
    String NAME_OF_CLIENT_INPUT = "STI701_S002_E042";
    String SALUTATION_COMBOBOX = "STI701_S002_C003";
    String INFLECT_CLIENT_NAME_INPUT = "STI701_S002_E001";
    String TASK_ID_INPUT = "STI701_S002_E002";
    String EMAIL_ADDRESS_INPUT = "STI701_S002_E004";
    String MONETA_MONEY_BANK_RADIO = "STI701_S002_R002_1";
    String FIST_TASK_FILE_CHECKBOX = "STI701_S002_G003-0";
    String SEND_EMAIL_BUTTON = "STI701_S002_B002";

    @Click(value = SENDING_FINAL_STATEMENT_RADIO, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STI701_S002_EmailPanel clickSendingFinalStatement();

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

    @Select(SALUTATION_COMBOBOX)
    STI701_S002_EmailPanel selectSalutation(String salutation);

    @TypeInto(INFLECT_CLIENT_NAME_INPUT)
    STI701_S002_EmailPanel fillInflectClientName(String inflection);

    @CustomAction
    default STI701_S002_EmailPanel checkOverwrittenTaskId(String task_id) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(task_id, endpoint.getAttribute(TASK_ID_INPUT, "value"));
        return null;
    }

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

    @Click(MONETA_MONEY_BANK_RADIO)
    STI701_S002_EmailPanel clickMMB();

    @Click(FIST_TASK_FILE_CHECKBOX)
    STI701_S002_EmailPanel clickTaskFile();

    @Click(SEND_EMAIL_BUTTON)
    HUS701_S001_WarningPage clickSendEmail();
}
