import {axios} from "@/requests/axios.config";

const prefix = "/announcement";

function createAnnouncement(data) {
  return axios.post(`${prefix}`, data);
}

function getAnnouncementsByCourseId(courseId) {
  return axios.get(`${prefix}/getAllByCourseId`, {params: {courseId,}});
}

function getAnnouncementById(id) {
  return axios.get(`${prefix}`, {params: {id}});
}

function updateAnnouncement(data) {
  return axios.put(`${prefix}`, data);
}

function deleteAnnouncement(id) {
  return axios.delete(`${prefix}`, {
    params: {
      id
    }
  });
}

function getUnreadAnnouncements() {
  return axios.get(`${prefix}/getUnreadByUserId`);
}

function readAnnouncement(id) {
  return axios.put(`${prefix}/read`, {id});
}

const announcementAPIs = {
  createAnnouncement,
  getAnnouncementById,
  getAnnouncementsByCourseId,
  updateAnnouncement,
  deleteAnnouncement,
  getUnreadAnnouncements,
  readAnnouncement,
};

export default announcementAPIs;