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

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

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

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

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

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