import { apiRequest } from '@/shared/api/client'
import type { CreatedIdResponse, GenreDto } from '@/shared/api/types'

export function listGenres() {
  return apiRequest<GenreDto[]>('/admin/genres')
}

export function createGenre(body: { name: string; slug: string; aliases?: string[] }) {
  return apiRequest<CreatedIdResponse>('/admin/genres', { method: 'POST', body })
}

export function updateGenre(
  id: string,
  body: { name: string; sortOrder: number; aliases?: string[] },
) {
  return apiRequest<void>(`/admin/genres/${id}`, { method: 'PUT', body })
}

export function deleteGenre(id: string) {
  return apiRequest<void>(`/admin/genres/${id}`, { method: 'DELETE' })
}
