const { Router } = require("express");
const { authMiddleware } = require("../middlewares/auth.middleware");
const { authorizeRoles } = require("../middlewares/role.middleware");
const { createSubject, updateSubject, getAllSubjects, getAllStudentSubjectsShow, getSubjectById, getSubjectsByTeacherId, getTeacherSubjects, getStudentSubjects, deleteSubject } = require("../controllers/subject.controller");
const subjectRouter = Router();

//teacher routes
subjectRouter.get("/teacher", authMiddleware, authorizeRoles("teacher"), getTeacherSubjects);
// GET subjects of a specific teacher (for admin/frontend)
subjectRouter.get("/teacher/:teacherId", authMiddleware, authorizeRoles("admin", "accountant"), getSubjectsByTeacherId);

//admin routes
subjectRouter.post("/create", authMiddleware, authorizeRoles("admin", "accountant"), createSubject);
subjectRouter.patch("/update/:id", authMiddleware, authorizeRoles("admin", "accountant"), updateSubject);
subjectRouter.get("/", getAllSubjects);
subjectRouter.get("/all-subject-list", authMiddleware, authorizeRoles("student"), getAllStudentSubjectsShow);
subjectRouter.get("/:id", authMiddleware, authorizeRoles("admin", "accountant"), getSubjectById);
subjectRouter.delete("/delete/:id", authMiddleware, authorizeRoles("admin", "accountant"), deleteSubject);

//student routes
subjectRouter.get("/student", authMiddleware, authorizeRoles("student"), getStudentSubjects);

module.exports = subjectRouter;