const { Router } = require("express");
const { authMiddleware } = require("../middlewares/auth.middleware");
const { authorizeRoles } = require("../middlewares/role.middleware");
const {
  createLiveClass,
  getAllLiveClasses,
  getClassesBySubject,
  endLiveClass,
  deleteLiveClass,
  getLiveClassesForTeacher,
} = require("../controllers/liveclass.controller");

const liveClassRouter = Router();

// Admin routes
liveClassRouter.post("/create", authMiddleware, authorizeRoles("admin", "accountant"), createLiveClass);
liveClassRouter.get("/", authMiddleware, getAllLiveClasses);
liveClassRouter.patch("/end/:id", authMiddleware, authorizeRoles("admin", "accountant"), endLiveClass);
liveClassRouter.delete("/delete/:id", authMiddleware, authorizeRoles("admin", "accountant"), deleteLiveClass);

// Teacher routes
liveClassRouter.get("/teacher", authMiddleware, authorizeRoles("teacher"), getLiveClassesForTeacher);
liveClassRouter.get("/subject/:subjectId", authMiddleware, authorizeRoles("teacher"), getClassesBySubject);

module.exports = liveClassRouter;
