// const express = require("express");
// const router = express.Router();
// const uomController = require("../../controllers/securityops/uomController");
// const authenticate = require("../../middlewares/authenticate")
// const authorize = require("../../middlewares/authorize")

// // CREATE
// router.post("/create",authenticate,authorize(["admin"]),  (req, res) => {
//   uomController.createUom(req, res);
// });


// // GET ALL
// router.get("/get/all", (req, res) => {
//   uomController.getAllUoms(req, res);
// });


// // UPDATE
// router.put("/update/:id",authenticate,authorize(["admin"]), (req, res) => {
//   uomController.updateUom(req, res);
// });


// // DELETE
// router.delete("/delete/:id",authenticate,authorize(["admin"]), (req, res) => {
//   uomController.deleteUom(req, res);
// });

// module.exports = router;

const express = require("express");
const router = express.Router();
const uomController = require("../../controllers/securityops/uomController");
const authenticate = require("../../middlewares/authenticate");
const authorize = require("../../middlewares/authorize");

/**
 * @swagger
 * tags:
 *   name: UOM Management
 *   description: Unit of Measurement management APIs
 */


// CREATE
router.post(
  "/create",
  authenticate,
  // authorize(["admin"]),
  (req, res) => {

    /*
      #swagger.tags = ['UOM Management']
      #swagger.summary = 'Create new unit of measurement'
      #swagger.security = [{ "bearerAuth": [] }]

      #swagger.requestBody = {
        required: true,
        content: {
          "application/json": {
            schema: {
              type: "object",
              required: ["name", "symbol"],
              properties: {
                name: {
                  type: "string",
                  example: "Kilogram"
                },
                symbol: {
                  type: "string",
                  example: "kg"
                },
                description: {
                  type: "string",
                  example: "Weight measurement unit"
                },
                isActive: {
                  type: "boolean",
                  example: true
                }
              }
            }
          }
        }
      }
    */

    uomController.createUom(req, res);
  }
);


// GET ALL
router.get(
  "/get/all",
  (req, res) => {

    /*
      #swagger.tags = ['UOM Management']
      #swagger.summary = 'Get all units of measurement'
    */

    uomController.getAllUoms(req, res);
  }
);


// UPDATE
router.put(
  "/update/:id",
  authenticate,
  // authorize(["admin"]),
  (req, res) => {

    /*
      #swagger.tags = ['UOM Management']
      #swagger.summary = 'Update unit of measurement'
      #swagger.security = [{ "bearerAuth": [] }]

      #swagger.parameters['id'] = {
        in: 'path',
        required: true,
        type: 'string',
        example: '665f3f0c8f9b123456789abc'
      }

      #swagger.requestBody = {
        required: true,
        content: {
          "application/json": {
            schema: {
              type: "object",
              properties: {
                name: {
                  type: "string",
                  example: "Kilogram"
                },
                symbol: {
                  type: "string",
                  example: "kg"
                },
                description: {
                  type: "string",
                  example: "Weight measurement unit"
                },
                isActive: {
                  type: "boolean",
                  example: true
                }
              }
            }
          }
        }
      }
    */

    uomController.updateUom(req, res);
  }
);


// DELETE
router.delete(
  "/delete/:id",
  authenticate,
  authorize(["admin"]),
  (req, res) => {

    /*
      #swagger.tags = ['UOM Management']
      #swagger.summary = 'Delete unit of measurement'
      #swagger.security = [{ "bearerAuth": [] }]

      #swagger.parameters['id'] = {
        in: 'path',
        required: true,
        type: 'string',
        example: '665f3f0c8f9b123456789abc'
      }
    */

    uomController.deleteUom(req, res);
  }
);

module.exports = router;