import { api } from 'src/boot/axios';
import type { EmployeeProfile } from 'src/modules/employee-list/models/employee-profile.models';
import type { BackendResponse } from 'src/modules/shared/models/backend-response.models';

export const EmployeeListService = {
    getEmployeeList: async (): Promise<BackendResponse<EmployeeProfile[]>> => {
        const response = await api.get<BackendResponse<EmployeeProfile[]>>('/employees/employee-list')
        return response.data;
        
    },

    getEmployeeDetails: async (): Promise<BackendResponse<EmployeeProfile>> => {
        const response = await api.get('employees/profile');
        return response.data;
    },

    getEmployeeDetailsWithEmployeeEmail: async (employee_email: string): Promise<BackendResponse<EmployeeProfile>> => {
        const response = await api.get(`employees/profile?employee_email=${employee_email}`);
        return response.data;
    },

    createNewEmployee: async (profile: Omit<EmployeeProfile, 'last_work_day' | 'birth_date'>): Promise<BackendResponse<EmployeeProfile>> => {
        const response = await api.post('employees/create', profile);
        return response.data;
    },

    updateEmployee: async (profile: EmployeeProfile): Promise<BackendResponse<EmployeeProfile>> => {
        const response = await api.patch('employees/update', profile);
        return response.data;
    },
};