import request from './request'
import type {
  TagGroup,
  CreateTagGroupRequest,
  UpdateTagGroupRequest,
  ReorderTagGroupsRequest,
} from '@/types'

export const tagGroupsApi = {
  getTagGroupsList: () => {
    return request.get<any, TagGroup[]>('/tag-groups')
  },

  getTagGroupById: (id: string) => {
    return request.get<any, TagGroup>(`/tag-groups/${id}`)
  },

  createTagGroup: (data: CreateTagGroupRequest) => {
    return request.post<any, TagGroup>('/tag-groups', data)
  },

  updateTagGroup: (id: string, data: UpdateTagGroupRequest) => {
    return request.patch<any, TagGroup>(`/tag-groups/${id}`, data)
  },

  deleteTagGroup: (id: string) => {
    return request.delete(`/tag-groups/${id}`)
  },

  reorderTagGroups: (data: ReorderTagGroupsRequest) => {
    return request.patch('/tag-groups/sort', data)
  },
}
