import api from './client';

export const apiGetAnnouncement = async ({ user, search, page }: { user: string, search: string, page?: number }) => {
   const response = await api.get(`mobile/announcement?user=${user}&search=${search}&page=${page}`);
   return response.data;
};

export const apiCreateAnnouncement = async (data: FormData) => {
   const response = await api.post(`/mobile/announcement`, data, {
      headers: { 'Content-Type': 'multipart/form-data' },
   })
   return response.data;
};

export const apiGetAnnouncementOne = async ({ user, id }: { user: string, id: string }) => {
   const response = await api.get(`mobile/announcement/${id}?user=${user}`);
   return response.data;
};

export const apiEditAnnouncement = async (data: FormData, id: string) => {
   const response = await api.put(`/mobile/announcement/${id}`, data, {
      headers: { 'Content-Type': 'multipart/form-data' },
   })
   return response.data;
};

export const apiDeleteAnnouncement = async (data: { user: string }, id: string) => {
   const response = await api.delete(`mobile/announcement/${id}`, { data })
   return response.data
};
