import { api } from '@/lib/api'
import type { Tag, PaginatedResponse } from '@/types/api'

export const tagService = {
    getAll: async (page = 1, limit = 10) => {
        // Admin endpoint returns PaginatedResponse usually, or maybe array.
        // Based on user/cors experience, let's assume PaginatedResponse or Array.
        // Given 'admin.Group("/tags")', it likely follows admin patterns.
        // Let's assume PaginatedResponse<Tag> for now, if not we fix it.
        const response = await api.get<PaginatedResponse<Tag>>('/v1/admin/tags', {
            params: { page, limit },
        })
        return response.data
    },

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

    create: async (data: Partial<Tag>) => {
        const response = await api.post<Tag>('/v1/admin/tags', data)
        return response.data
    },

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

    delete: async (id: string) => {
        await api.delete(`/v1/admin/tags/${id}`)
    }
}
