const express = require("express");
const router = express.Router();
const auth = require("../middleware/authMiddleware");
const adminMiddleware = require("../middleware/adminMiddleware");
const c = require("../controllers/training");

router.use(auth);

// Specific paths before /:id
router.get("/certificates", c.getMyCertificates);

router.get("/admin/all", adminMiddleware, c.getAllVideosAdmin);
router.get("/admin/report", adminMiddleware, c.getTrainingReport);
router.post("/admin/enroll", adminMiddleware, c.enrollUserInTraining);
router.post("/admin/video", adminMiddleware, c.createVideo);
router.patch("/admin/video/:id", adminMiddleware, c.updateVideo);
router.delete("/admin/video/:id", adminMiddleware, c.deleteVideo);

router.post("/:id/progress", c.saveProgress);
router.post("/:id/complete", c.completeVideo);

router.get("/", c.getTrainingVideos);

module.exports = router;
