import { apiClient } from './apiClient';
import { AssessmentTemplate, CreateTemplateData, UpdateTemplateData } from '../types';

export const templateService = {
  async getAll(): Promise<AssessmentTemplate[]> {
    const response = await apiClient.get<AssessmentTemplate[]>('/assessment/templates');
    return response.data;
  },

  async getById(id: string): Promise<AssessmentTemplate> {
    const response = await apiClient.get<AssessmentTemplate>(`/assessment/templates/${id}`);
    return response.data;
  },

  async create(data: CreateTemplateData): Promise<AssessmentTemplate> {
    const response = await apiClient.post<AssessmentTemplate>('/assessment/templates', data);
    return response.data;
  },

  async update(id: string, data: UpdateTemplateData): Promise<AssessmentTemplate> {
    const response = await apiClient.put<AssessmentTemplate>(`/assessment/templates/${id}`, data);
    return response.data;
  },

  async delete(id: string): Promise<void> {
    await apiClient.delete(`/assessment/templates/${id}`);
  },
};
