import { DiscountType } from "./Discounts.model";

export type CreateAppointmentParams = {
    companyId: string;
    serviceId: string;
    employeeId: string;
    userId?: string; // for user reservations
    clientId?: string; // for collaborator reservations
    repeatId?: string; //Para saber si tiene un descuento.
    start: string;
    length?: number;
    price?: number;
    comments?: string;
    validation?: boolean;
    notification?: boolean;
    sessionUser: string;
};

export type UpdateAppointmentParams = {
    id: string;
    start: string;
    length: number;
    price: number;
    comments: string;
    validation?: boolean;
    notification?: boolean;
    sessionUser: string;
};

export enum APPOINTMENT_NOTIFICATION_TYPE {
    "CREATION" = "creation",
    "REMINDER" = "reminder",
}

export type SendAppointmentNotificationParams = {
    appointmentId: string;
    sessionUser: string;
    type: APPOINTMENT_NOTIFICATION_TYPE;
};

export type DeleteAppointmentParams = {
    id: string;
    validation?: boolean;
    sessionUser: string;
};

export type FindAppointmentSchedulesParams = {
    companyId: string;
    serviceId: string;
    employeeId: string;
    dateDay: string | Date;
};

export type GetAvailableDatesParams = {
    companyId: string;
    serviceId: string;
    employeeId: string;
    length: number;
    sessionUser: string;
};

export type GetAvailableDatesResult = {
    availableDates: Date[];
    inRangeDates: Date[];
};

export interface GetAppointmentEventParams {
    appointmentId: string;
    sessionUser: string;
}

export interface IAppointment {
    id?: string;
    companyId: string;
    serviceId: string;
    employeeId: string;
    clientId: string;

    discountId: string;
    discountType: DiscountType;
    discountValue: number;
    discountName: string;
    discountCode: string;

    datetime: Date;
    length: number;
    price: number;
    present: boolean;
    payment: boolean;
    comments: string;
    creationDate: Date;
}

export type FindAppointmentsParams = {
    _id?: string;
    companyId?: string;
    serviceId?: string;
    employeeId?: string;
    clientId?: string;
    start?: string;
    dateDay?: string;
};

export type FindAppointmentsByUserParams = {
    sessionUser: string;
};

export type FindAppointmentsByUserPaginatedParams = FindAppointmentsByUserParams & {
    page: number;
    limit: number;
};

export type FindAppointmentsByCollaboratorParams = {
    sessionUser: string;
};

export type FindAppointmentsByCollaboratorPaginatedParams = FindAppointmentsByCollaboratorParams & {
    page: number;
    limit: number;
};

export interface AppointmentEvent {
    appointmentId: string;
    startTime: number;
    endTime: number;
    title: string;
    clientId: string;
    serviceId: string;
    employeeId: string;
    avatar: string;
    color: string;
    repeatId: string;

    discountId: string;
    discountType: DiscountType;
    discountValue: number;
    discountName: string;
    discountCode: string;
}

export interface AppointmentAdminByDateView {
    events: AppointmentEvent[];
    from: number;
    to: number;
}

export interface AppointmentEventByClient {
    id: string;
    companyId: string;
    serviceId: string;
    serviceName: string;
    serviceDescription: string;
    collaboratorId: string;
    collaboratorName: string;
    collaboratorAvatar: string;
    appointmentDate: string;
    startTime: number;
    endTime: number;
    title: string;
    clientId: string;
    clientName: string;
    avatar: string;
    color: string;
    comments: string;
    price: number;
    length: number;
    payment: boolean;

    discountId: string;
    discountType: DiscountType;
    discountValue: number;
    discountName: string;
    discountCode: string;

    clientCtaCteBalance: number;
}

export interface AppointmentAdminByClientView {
    events: AppointmentEventByClient[];
}

export interface PaginatedAppointmentEventByClientResult {
    data: AppointmentEventByClient[];
    page: number;
    pages: number;
}

export type ApplyAppointmentDiscountParams = {
    companyId: string;
    appointmentId: string;
    discountId: string;
    sessionUser: string;
};

export type DeleteAppointmentDiscountParams = {
    appointmentId: string;
    companyId: string;
    sessionUser: string;
};

export type ChangeServiceParams = {
    id: string;
    newServiceId: string;
    newEmployeeId: string;
    sessionUser: string;
};
