import api from './api';

export interface TaskTemplate {
    id: string;
    title: string;
    description?: string;
    roomType?: string;
    estimatedMinutes?: number;
    materials?: string[];
    recurrence?: any;
    createdAt: string;
    updatedAt: string;
}

export interface CreateTaskTemplateData {
    title: string;
    description?: string;
    roomType?: string;
    estimatedMinutes?: number;
    materials?: string[];
    recurrence?: any;
}

export const taskTemplatesApi = {
    getAll: async () => {
        const response = await api.get<TaskTemplate[]>('/task-templates');
        return response.data;
    },

    create: async (data: CreateTaskTemplateData) => {
        const response = await api.post<TaskTemplate>('/task-templates', data);
        return response.data;
    },

    update: async (id: string, data: Partial<CreateTaskTemplateData>) => {
        const response = await api.patch<TaskTemplate>(`/task-templates/${id}`, data);
        return response.data;
    },

    delete: async (id: string) => {
        await api.delete(`/task-templates/${id}`);
    }
};
