import { api } from '@/lib/axios'

export type CategoriesProps = {
  id: string
  name: string
}

export async function createCategories({ name }: CategoriesProps) {
  const categories = await api.post<CategoriesProps>('/categories', {
    name,
  })
  return categories
}

export async function getCategories() {
  const categories = await api.get<CategoriesProps[]>('/categories')
  return categories
}

export async function getCategoryId(id: string) {
  const categories = await api.get<CategoriesProps>(`/categories/${id}`)
  return categories
}

export async function editCategoryId(data: CategoriesProps) {
  const categories = await api.put<CategoriesProps>(`/categories/${data.id}`, {
    name: data.name,
  })
  return categories
}

export async function deleteCategory(id: string) {
  const categories = await api.delete(`/categories/${id}`)
  return categories
}
