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

/**
 * @swagger
 * tags:
 *   name: Parking Management
 *   description: Commercial vehicle parking slot APIs
 */


router.post("/bay/create",
  authenticate,
  // authorize(["admin", "security"]),
  (req, res) =>{
      /*
      #swagger.tags = ['Parking Management ']
      #swagger.summary = 'Create available commercial parking slots'
      #swagger.security = [{ "bearerAuth": [] }]
    */
     parkingController.createBay(req, res)
  }
);

router.put("/update-bay/:id",
  authenticate,
  authorize(["admin", "security"]),
  (req, res) =>{
      /*
      #swagger.tags = ['Parking Management ']
      #swagger.summary = 'Update commercial parking slots'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    parkingController.updateBay(req, res)
  }
);

router.get(
  "/commercial/availability",
  authenticate,
  // authorize(["admin", "security", "qc"]),
  (req, res) => {
    /*
      #swagger.tags = ['Parking Management ']
      #swagger.summary = 'Get available commercial parking slots'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    parkingController.getCommercialParkingAvailability(req, res);
  }
);


router.post(
  "/assign-slot",
  authenticate,
  authorize(["admin", "security", "qc"]),
  (req, res) => {

    /*
      #swagger.tags = ['Parking Management ']
      #swagger.summary = 'Assign parking slot to commercial vehicle'
      #swagger.security = [{ "bearerAuth": [] }]

      #swagger.requestBody = {
        required: true,
        content: {
          "application/json": {
            schema: {
              type: "object",
              required: ["bayCode", "slot", "vehicleNumber"],
              properties: {
                bayCode: { type: "string", example: "BAY-A" },
                slot: { type: "string", example: "A-12" },
                vehicleNumber: { type: "string", example: "TS09AB1234" },
                driverName: { type: "string", example: "Ramesh Kumar" },
                referenceNo: { type: "string", example: "REF-2026-001" }
              }
            }
          }
        }
      }
    */

    parkingController.assignSlot(req, res);
  }
);

module.exports = router;