import request from '@/utils/http'

const GROUP_BASE_URL = '/api/admin/v1/dictionary/groups'

export function getItems(groupId: string) {
  return request.get<Api.Dictionary.DictionaryItemDto[]>({
    url: `${GROUP_BASE_URL}/${groupId}/items`
  })
}

export function createItem(groupId: string, data: Api.Dictionary.CreateDictionaryItemRequest) {
  return request.post<Api.Dictionary.DictionaryItemDto>({
    url: `${GROUP_BASE_URL}/${groupId}/items`,
    data
  })
}

export function updateItem(
  groupId: string,
  itemId: string,
  data: Api.Dictionary.UpdateDictionaryItemRequest
) {
  return request.put<Api.Dictionary.DictionaryItemDto>({
    url: `${GROUP_BASE_URL}/${groupId}/items/${itemId}`,
    data
  })
}

export function deleteItem(groupId: string, itemId: string) {
  return request.del<void>({
    url: `${GROUP_BASE_URL}/${groupId}/items/${itemId}`
  })
}
