import { TextObjectFilterResult } from "../../Models/TextObjectFilter.model";

export type FindEmployeesServicesParams = {
    _id?: string;
    companyId?: string;
    employeeId?: string;
    serviceId?: string;
};

export type FindEmployeesByServiceParams = {
    serviceId?: string;
};

export type PaginateEmployeesServicesParams = FindEmployeesServicesParams & {
    page: number;
    limit: number;
};

export type PaginateEmployeesServicesResults = {
    data: IEmployeeService[];
    page: number;
    pages: number;
};

export type CreateEmployeeServiceParams = {
    companyId: string;
    serviceId: string;
    employeeId: string;
    price?: number;
    sessionUser: string;
};

export type UpdateEmployeeServiceParams = CreateEmployeeServiceParams & {
    id: string;
};

export type DeleteEmployeeServiceParams = {
    companyId: string;
    employeeId: string;
    serviceId: string;
    sessionUser: string;
};

export interface IEmployeeService {
    id?: string;
    companyId: string;
    employeeId: string;
    serviceId: string;
    price?: number;
}

export type FindCollaboratorServicesParams = {
    companyId: string;
    employeeId: string;
    sessionUser: string;
};

export type UpdateCollaboratorServicesParams = {
    companyId: string;
    employeeId: string;
    services: ServiceStatusItem[];
    sessionUser: string;
};

export type DeleteEmployeeServiceByCompanyParams = {
    companyId: string;
};

export type DeleteEmployeeServiceByEmployeeParams = {
    employeeId: string;
};

export interface CollaboratorServiceItems {
    id: string;
    name: string;
    description: string;
    length: number;
    price: number;
    limit: number;
    active: boolean;
}

export interface CollaboratorServiceView {
    companyId: string;
    employeeId: string;
    fullName: string;
    avatar: string;
    services: CollaboratorServiceItems[];
}

export interface ServiceStatusItem {
    serviceId: string;
    active: boolean;
}

export interface IEmployeesServicesAdapter {
    create(data: CreateEmployeeServiceParams): Promise<IEmployeeService>;
    update(data: UpdateEmployeeServiceParams): Promise<void>;
    delete(id: string): Promise<void>;
    find(filters: FindEmployeesServicesParams): Promise<IEmployeeService[]>;
    findOne(filters: FindEmployeesServicesParams): Promise<IEmployeeService | null>;
    paginate(filters: PaginateEmployeesServicesParams): Promise<PaginateEmployeesServicesResults>;
}

export interface IEmployeesServicesManager {
    employeesServices: IEmployeesServicesAdapter;
    createEmployeeService(data: CreateEmployeeServiceParams): Promise<IEmployeeService>;
    updateEmployeeService(data: UpdateEmployeeServiceParams): Promise<void>;
    updateCollaboratorServices(data: UpdateCollaboratorServicesParams): Promise<void>;
    find(data: FindEmployeesServicesParams): Promise<IEmployeeService[]>;
    findAllServicesByCollaborator(
        data: FindEmployeesServicesParams
    ): Promise<CollaboratorServiceView>;
    delete(data: DeleteEmployeeServiceParams): Promise<void>;
    textObjectFilter(data: FindEmployeesServicesParams): Promise<TextObjectFilterResult[]>;
    findByService(data: FindEmployeesByServiceParams): Promise<TextObjectFilterResult[]>;
    deleteEmployeeServiceByCompany(data: DeleteEmployeeServiceByCompanyParams): Promise<void>;
    deleteEmployeeServiceByEmployee(data: DeleteEmployeeServiceByEmployeeParams): Promise<void>;
}
