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

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

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

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

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

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