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

export type AreasProps = {
  id?: string
  name: string
  desktopBanner: string | null
  mobileBanner: string | null
}

export async function createAreas({
  name,
  desktopBanner,
  mobileBanner,
}: AreasProps) {
  const area = await api.post<AreasProps[]>('/areas', {
    name,
    desktopBanner,
    mobileBanner,
  })
  return area
}

export async function editArea({
  id,
  name,
  desktopBanner,
  mobileBanner,
}: AreasProps) {
  const area = await api.put<AreasProps[]>(`/areas/${id}`, {
    name,
    desktopBanner,
    mobileBanner,
  })
  return area
}

export async function getAreas() {
  const areas = await api.get<AreasProps[]>('/areas')
  return areas
}

export async function getAreasId(id: string) {
  const area = await api.get<AreasProps>(`/areas/${id}`)
  return area
}

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