academicYear logic

This commit is contained in:
amNobodyyy
2025-01-27 23:34:51 +05:30
parent 805d866190
commit 4466b33dff
9 changed files with 138 additions and 88 deletions

View File

@@ -14,7 +14,7 @@ router.post("/", async (req, res) => {
const savedAppointments = [];
for (const appointment of appointments) {
const { facultyId, courseId, tasks, examPeriod } = appointment;
const { facultyId, courseId, tasks, examPeriod, academicYear } = appointment;
if (
!facultyId ||
@@ -43,6 +43,7 @@ router.post("/", async (req, res) => {
courseName: course.name,
task,
examPeriod,
academicYear,
});
const savedAppointment = await newAppointment.save();
savedAppointments.push(savedAppointment);
@@ -58,8 +59,9 @@ router.post("/", async (req, res) => {
// Get all appointments
router.get("/", async (req, res) => {
const { academicYear } = req.query;
try {
const appointments = await Appointment.find();
const appointments = await Appointment.find({ academicYear });
res.json(appointments);
} catch (error) {
console.error("Error fetching appointments:", error);