const { Router } = require("express");
const { authMiddleware } = require("../middlewares/auth.middleware");
const { authorizeRoles } = require("../middlewares/role.middleware");
const {
  createSalary,
  updateSalary,
  getTeacherSalary,
  getMySalary,
  getAllSalaries, // new
} = require("../controllers/salary.controller");

const salaryRouter = Router();

// Admin routes
salaryRouter.post("/create", authMiddleware, authorizeRoles("admin", "accountant"), createSalary);
salaryRouter.patch("/update/:id", authMiddleware, authorizeRoles("admin", "accountant"), updateSalary);
salaryRouter.get("/teacher/:id", authMiddleware, authorizeRoles("admin", "accountant"), getTeacherSalary);
salaryRouter.get("/", authMiddleware, authorizeRoles("admin", "accountant"), getAllSalaries); // new

// Teacher route
salaryRouter.get("/my-salary", authMiddleware, authorizeRoles("teacher"), getMySalary);

module.exports = salaryRouter;
