import ApiRequest from "@services/Api.Service";
import {
    CompanyEmployeesView,
    FindEmployeesParams,
    CreateEmployeeParams,
    IEmployee,
    ValidateEmployeeParams,
    FindEmployeesByIdParams,
    UpdateEmployeeRolesParams,
    FindCollaboratorServicesParams,
    CollaboratorServiceView,
    UpdateCollaboratorServicesParams,
    FindSchedulesParams,
    CollaboratorSchedulesView,
    UpdateScheduleParams,
    UpdateEmployeeParams,
} from "@models/Collaborators.model";
import { CollaboratorView, FindCollaboratorByEmailParams } from "@models/User.model";
import { ApiVoidResult } from "@models/Api.VoidResult.type";
import {
    CreateSchedulesDisabledParams,
    DeleteSchedulesDisabledParams,
    FindSchedulesDisabledParams,
    SchedulesDisabledByCollaboratorView,
} from "@core/Models/SchedulesDisabled";
import {
    FindSchedulesOverridesParams,
    CreateSchedulesOverridesParams,
    UpdateSchedulesOverridesParams,
    DeleteSchedulesOverridesParams,
    ISchedulesOverrides,
} from "@core/Models/SchedulesOverrides";

export const loadCollaboratorsByCompanyId = async (
    data: FindEmployeesParams
): Promise<CompanyEmployeesView[]> => {
    return ApiRequest.post<CompanyEmployeesView[]>("employees/get-by-company", data);
};

export const findCollaboratorsByEmail = async (
    data: FindCollaboratorByEmailParams
): Promise<CollaboratorView | null> => {
    return ApiRequest.post<CollaboratorView | null>("users/get-by-email", data);
};

export const findCollaboratorsById = async (
    data: FindEmployeesByIdParams
): Promise<CompanyEmployeesView | null> => {
    return ApiRequest.post<CompanyEmployeesView | null>("employees/get-by-id", data);
};

export const findCollaboratorsServices = async (
    data: FindCollaboratorServicesParams
): Promise<CollaboratorServiceView | null> => {
    return ApiRequest.post<CollaboratorServiceView | null>("employees/get-all-services", data);
};

export const findCollaboratorsSchedules = async (
    data: FindSchedulesParams
): Promise<CollaboratorSchedulesView> => {
    return ApiRequest.post<CollaboratorSchedulesView>("schedules/get-all-by-collaborator", data);
};

export const updateCollaboratorsServices = async (
    data: UpdateCollaboratorServicesParams
): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("employees/update-collaborator-services", data);
};

export const updateCollaboratorsSchedules = async (data: UpdateScheduleParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("schedules/update", data);
};

export const createCollaborator = async (data: CreateEmployeeParams): Promise<IEmployee> => {
    return ApiRequest.post<IEmployee>("employees/create", data);
};

export const validateGuestCollaborator = async (data: ValidateEmployeeParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("employees/validate-guest", data);
};

export const validateHostCollaborator = async (data: ValidateEmployeeParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("employees/validate-host", data);
};

export const updateCollaboratorRoles = async (data: UpdateEmployeeRolesParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("employees/update-roles", data);
};

export const updateCollaborator = async (data: UpdateEmployeeParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("employees/update", data);
};

export const findSchedulesDisabledByCollaborator = async (
    data: FindSchedulesDisabledParams
): Promise<SchedulesDisabledByCollaboratorView> => {
    return ApiRequest.post<SchedulesDisabledByCollaboratorView>(
        "schedules-disabled/find-by-collaborator",
        data
    );
};

export const createScheduleDisabled = async (data: CreateSchedulesDisabledParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("schedules-disabled/create", data);
};

export const deleteScheduleDisabled = async (data: DeleteSchedulesDisabledParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("schedules-disabled/delete", data);
};

export const getSchedulesOverrides = async (
    data: FindSchedulesOverridesParams
): Promise<ISchedulesOverrides[]> => {
    return ApiRequest.post<ISchedulesOverrides[]>(
        "schedules-overrides/get",
        data
    );
};

export const createSchedulesOverrides = async (data: CreateSchedulesOverridesParams): Promise<ISchedulesOverrides> => {
    return ApiRequest.post<ISchedulesOverrides>("schedules-overrides/create", data);
};

export const updateSchedulesOverrides = async (data: UpdateSchedulesOverridesParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("schedules-overrides/update", data);
};

export const deleteSchedulesOverrides = async (data: DeleteSchedulesOverridesParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("schedules-overrides/delete", data);
};
