import { api } from './client'

export async function fetchAnnouncements() {
  const { data } = await api.get('/announcements')
  return data
}

export async function createAnnouncement(payload) {
  const { data } = await api.post('/announcements', payload)
  return data
}

export async function uploadAnnouncementImage(file) {
  const formData = new FormData()
  formData.append('file', file)
  const { data } = await api.post('/announcements/upload_image', formData)
  return data
}

export async function activateAnnouncement(id) {
  const { data } = await api.post(`/announcements/${id}/activate`)
  return data
}

export async function deactivateAnnouncement(id) {
  const { data } = await api.post(`/announcements/${id}/deactivate`)
  return data
}

export async function deleteAnnouncement(id) {
  const { data } = await api.delete(`/announcements/${id}`)
  return data
}
