import {
    MyOranizationsView,
    UpdateCompanyParams,
    OranizationsViewByIdParams,
    SetOrganizationPublishedStatusParams,
} from "@models/Company.model";
import { ApiVoidResult } from "@models/Api.VoidResult.type";
import ApiRequest from "@services/Api.Service";
import {
    EnableScheduleParams,
    FindSchedulesEnabledParams,
    SchedulesEnabledView,
} from "@models/SchedulesEnabled.type";
import {
    CreatePaymentParams,
    DeletePaymentParams,
    FindPaymentsParams,
    IPayment,
    PaginateNotPayedAppointmentsParams,
    PaginateNotPayedAppointmentsResult,
    PaginatePaymentsViewParams,
    PaginatePaymentsViewResults,
    NotPayedReportResult,
    PaymentsReportResult,
} from "@core/Models/Payments.model";

export const savePublishedStatus = async (
    data: SetOrganizationPublishedStatusParams
): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("companies/set-published-status", data);
};

export const loadOrganizationsById = async (
    data: OranizationsViewByIdParams
): Promise<MyOranizationsView> => {
    return ApiRequest.post<MyOranizationsView>("companies/get-by-id", data);
};

export const updateOrganizationsById = async (
    data: UpdateCompanyParams
): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("companies/update", data);
};

export const loadSchedulesEnabled = async (
    data: FindSchedulesEnabledParams
): Promise<SchedulesEnabledView[]> => {
    return ApiRequest.post<SchedulesEnabledView[]>("schedules-enabled/find", data);
};

export const enableSchedule = async (data: EnableScheduleParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("schedules-enabled/enable", data);
};

export const disableSchedule = async (data: EnableScheduleParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("schedules-enabled/disable", data);
};

export const uploadHeaderImage = async (data: FormData): Promise<ApiVoidResult> => {
    return ApiRequest.postFile<ApiVoidResult>("companies/upload-header", data);
};

export const loadPaymentsViewTotal = async (data: FindPaymentsParams): Promise<number> => {
    return ApiRequest.post<number>("payments/paginated-view-total", data);
};

export const loadPaymentsView = async (
    data: PaginatePaymentsViewParams
): Promise<PaginatePaymentsViewResults> => {
    return ApiRequest.post<PaginatePaymentsViewResults>("payments/paginate-view", data);
};

export const paginateNotPayedAppointments = async (
    data: PaginateNotPayedAppointmentsParams
): Promise<PaginateNotPayedAppointmentsResult> => {
    return ApiRequest.post<PaginateNotPayedAppointmentsResult>("payments/not-payed", data);
};

export const paginateNotPayedAppointmentsTotal = async (
    data: FindPaymentsParams
): Promise<number> => {
    return ApiRequest.post<number>("payments/not-payed-total", data);
};

export const payNotPayedAppointments = async (data: FindPaymentsParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("payments/pay-not-payed", data);
};

export const GetNotPayedReport = async (
    data: FindPaymentsParams
): Promise<NotPayedReportResult> => {
    return ApiRequest.post<NotPayedReportResult>("payments/get-not-payed-report", data);
};

export const deletePayment = async (data: DeletePaymentParams): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("payments/delete", data);
};

export const createPayment = async (data: CreatePaymentParams): Promise<IPayment> => {
    return ApiRequest.post<IPayment>("payments/create", data);
};

export const GetPaymentsReport = async (
    data: FindPaymentsParams
): Promise<PaymentsReportResult> => {
    return ApiRequest.post<PaymentsReportResult>("payments/get-payments-report", data);
};
