const express = require("express");
const {
  getAllDepartmentEmails,
  getDepartmentsByProgram,
  getEmailsByDepartment,
  updateDepartmentEmails,
  createDepartment,
  deleteDepartment,
} = require("../controllers/departmentController");

const router = express.Router();

router.get("/programs", async (req, res) => {
  const Program = require("../models/Program");
  const programs = await Program.find();
  res.json(programs);
});

router.get("/departments/:program", getDepartmentsByProgram);
router.get("/department-emails/:department", getEmailsByDepartment);
router.get("/department-emails", getAllDepartmentEmails);
router.put("/department-emails/:department", updateDepartmentEmails);
router.post("/department-emails", createDepartment);
router.delete("/department-emails/:department", deleteDepartment);

module.exports = router;
