import { api } from "@/lib/api"
import type { Education } from "@/types/api"

export const educationService = {
    getAll: async (resumeId?: string): Promise<Education[]> => {
        const params = resumeId ? { resume_id: resumeId } : {}
        const response = await api.get<Education[]>("/v1/admin/educations", { params })
        return response.data
    },

    getById: async (id: string): Promise<Education> => {
        const response = await api.get<Education>(`/v1/admin/educations/${id}`)
        return response.data
    },

    create: async (data: Partial<Education>): Promise<Education> => {
        const response = await api.post<Education>("/v1/admin/educations", data)
        return response.data
    },

    update: async (id: string, data: Partial<Education>): Promise<Education> => {
        const response = await api.put<Education>(`/v1/admin/educations/${id}`, data)
        return response.data
    },

    delete: async (id: string): Promise<void> => {
        await api.delete(`/v1/admin/educations/${id}`)
    }
}
