import { ISchedulesOverridesDocument } from "./SchedulesOverrides.Adapter.Mongoose";
import { ScheduleItem } from "../Schedules/Schedules.Interface";

export type FindSchedulesOverridesParams = {
    _id?: string;
    companyId?: string;
    employeeId?: string;
    date?: Date;
};

export type AvailableSchedulesOverridesParams = {
    companyId: string;
    employeeId: string;
    dateDay: Date;
    from: string;
    to: string;
};

export type PaginateSchedulesOverridesParams = FindSchedulesOverridesParams & {
    page: number;
    limit: number;
};

export type PaginateSchedulesOverridesResults = {
    data: ISchedulesOverrides[];
    page: number;
    pages: number;
};

export type CreateSchedulesOverridesParams = {
    companyId: string;
    employeeId: string;
    schedules: Array<ScheduleItem>;
    date: Date;
    sessionUser: string;
};

export type UpdateSchedulesOverridesParams = {
    companyId: string;
    employeeId: string;
    schedules: Array<ScheduleItem>;
    date: Date;
    sessionUser: string;
};

export type DeleteSchedulesOverridesParams = {
    id: string;
    companyId: string;
    sessionUser: string;
};

export type DeleteSchedulesOverridesByCompanyParams = {
    companyId: string;
};

export type DeleteSchedulesOverridesByEmployeeParams = {
    employeeId: string;
};

export interface ISchedulesOverrides {
    id?: string;
    companyId: string;
    employeeId: string;
    schedules: Array<ScheduleItem>;
    date: Date;
}

export interface ISchedulesOverridesAdapter {
    create(data: CreateSchedulesOverridesParams): Promise<ISchedulesOverrides>;
    update(data: UpdateSchedulesOverridesParams): Promise<void>;
    delete(id: string): Promise<void>;
    find(filters: FindSchedulesOverridesParams): Promise<ISchedulesOverrides[]>;
    findOne(filters: FindSchedulesOverridesParams): Promise<ISchedulesOverridesDocument | null>;
    paginate(filters: PaginateSchedulesOverridesParams): Promise<PaginateSchedulesOverridesResults>;
}

export interface ISchedulesOverridesManager {
    schedulesOverrides: ISchedulesOverridesAdapter;
    createSchedulesOverrides(data: CreateSchedulesOverridesParams): Promise<ISchedulesOverrides>;
    updateSchedulesOverrides(data: UpdateSchedulesOverridesParams): Promise<void>;
    find(data: FindSchedulesOverridesParams): Promise<ISchedulesOverrides[]>;
    findOne(data: FindSchedulesOverridesParams): Promise<ISchedulesOverrides | null>;
    delete(data: DeleteSchedulesOverridesParams): Promise<void>;
    isAvailable(data: AvailableSchedulesOverridesParams): Promise<boolean>;
    deleteSchedulesOverridesByCompany(data: DeleteSchedulesOverridesByCompanyParams): Promise<void>;
    deleteSchedulesOverridesByEmployee(data: DeleteSchedulesOverridesByEmployeeParams): Promise<void>;
}
