const express = require("express");
const router = express.Router();
const roleControlller = require("../../controllers/admin/roleController");
const authenticate = require("../../middlewares/authenticate");
const authorize = require("../../middlewares/authorize");

/**
 * @swagger
 * tags:
 *   name: Roles
 *   description: Role & Permission Management
 */

// router.put("/update-permission",authenticate, authorize(["superadmin", "admin"]), (req,res) => {
//    roleControlller.updatePermission(req, res)
// });

// router.get("/:role/get-permission", authenticate, authorize(["superadmin", "admin"]), (req,res) => {
//     roleControlller.getRolePermissions(req, res)
// })

// router.get("/getAll", authenticate,authorize(["superadmin", "admin"]),(req,res) => {
//     roleControlller.getAllRoles(req, res)
// })

router.put("/update-permission", authenticate, authorize(["superadmin", "admin"]), (req, res) => {
    /*
      #swagger.tags = ['Roles']
      #swagger.summary = 'Update role permissions'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    roleControlller.updatePermission(req, res);
});

router.get("/:role/get-permission", authenticate, authorize(["superadmin", "admin"]), (req, res) => {
    /*
      #swagger.tags = ['Roles']
      #swagger.summary = 'Get role permissions'
      #swagger.security = [{ "bearerAuth": [] }]
      #swagger.parameters['role'] = { description: 'Role name', required: true }
    */
    roleControlller.getRolePermissions(req, res);
});

router.get("/getAll", authenticate, authorize(["superadmin", "admin"]), (req, res) => {
    /*
      #swagger.tags = ['Roles']
      #swagger.summary = 'Get all roles'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    roleControlller.getAllRoles(req, res);
});


router.get("/getAlls", authenticate, (req, res) => {
  console.log("routesssssssssssssssssssss")
    /*
      #swagger.tags = ['Roles']
      #swagger.summary = 'Get all roles'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    roleControlller.getRoles(req, res);
}
)
module.exports = router;
