targo-frontend/src/modules/timesheets/services/shift-service.ts

35 lines
1.4 KiB
TypeScript

import { api } from "src/boot/axios";
import type { BackendResponse } from "src/modules/shared/models/backend-response.models";
import type { Shift } from "src/modules/timesheets/models/shift.models";
export const ShiftService = {
deleteShiftById: async (shift_id: number, employee_email?: string) => {
if (employee_email) {
const response = await api.delete(`/shift/${shift_id}/${employee_email}`);
return response.data;
}
const response = await api.delete(`/shift/${shift_id}`);
return response.data;
},
createNewShifts: async (new_shifts: Shift[], employee_email?: string):Promise<BackendResponse<Shift>> => {
if (employee_email) {
const response = await api.post(`/shift/create/${employee_email}`, new_shifts);
return response.data;
}
const response = await api.post(`/shift/create`, new_shifts);
return response.data;
},
updateShifts: async (existing_shifts: Shift[], employee_email?: string):Promise<BackendResponse<Shift>> => {
if (employee_email) {
const response = await api.patch(`/shift/update/${employee_email}`, existing_shifts);
return response.data;
}
const response = await api.patch(`/shift/update`, existing_shifts);
return response.data;
}
};