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

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

export async function createAudiences({ name }: AudiencesProps) {
  const audiences = await api.post<AudiencesProps>('/audiences', {
    name,
  })
  return audiences
}

export async function getAudiences() {
  const audiences = await api.get<AudiencesProps[]>('/audiences')
  return audiences
}

export async function getAudienceId(id: string) {
  const audiences = await api.get<AudiencesProps>(`/audiences/${id}`)
  return audiences
}

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

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