import { api } from "src/boot/axios";
import type { SchedulePreset } from "src/modules/employee-list/models/schedule-presets.models";
import type { BackendResponse } from "src/modules/shared/models/backend-response.models";

export const SchedulePresetsService = {
    createSchedulePresets: async (preset: SchedulePreset): Promise<BackendResponse<SchedulePreset>> => {
        const response = await api.post(`/schedule-presets/create/`, preset);
        return response.data;
    },

    updateSchedulePresets: async (preset: SchedulePreset): Promise<BackendResponse<boolean>> => {
        const response = await api.patch(`/schedule-presets/update`, preset);
        return response.data;
    },

    deleteSchedulePresets: async (preset_id: number): Promise<BackendResponse<boolean>> => {
        const response = await api.delete(`/schedule-presets/delete/${preset_id}`);
        return response.data;
    },

    getSchedulePresetsList: async (): Promise<BackendResponse<SchedulePreset[]>> => {
        const response = await api.get(`/schedule-presets/find-list`);
        return response.data;
    },

    applyPresets: async (preset_name: string, start_date: string) => {
        const response = await api.post(`/schedule-presets/apply-presets/`, { preset: preset_name, start: start_date });
        return response.data;
    },
};