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

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

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

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

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

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