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

export type ModulesProps = {
  id: string
  name: string
  description: string
}

export async function createModules({ name, description }: ModulesProps) {
  const modules = await api.post<ModulesProps>('/modules', {
    name,
    description,
  })
  return modules
}

export async function editModule({ id, name, description }: ModulesProps) {
  const modules = await api.patch<ModulesProps[]>(`/modules/${id}`, {
    name,
    description,
  })
  return modules
}

export async function getModules() {
  const modules = await api.get<ModulesProps[]>('/modules')
  return modules
}

export async function getModulesId(id: string) {
  const modules = await api.get<ModulesProps>(`/modules/${id}`)
  return modules
}

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