// const express = require("express");
// const router = express.Router();
// const branchController = require("../controllers/branchController");

// /**
//  * @swagger
//  * tags:
//  *   name: Public Branches
//  *   description: Public (No Auth) Branch Management APIs
//  */

// // CREATE branch (Public)
// router.post(
//   "/create",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Branches']
//       #swagger.summary = 'Create branch (Public)'
//     */
//     branchController.createBranch(req, res);
//   }
// );

// // GET all branches (Public)
// router.get(
//   "/",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Branches']
//       #swagger.summary = 'Get all branches (Public)'
//       #swagger.parameters['search'] = { in: 'query', type: 'string' }
//       #swagger.parameters['page'] = { in: 'query', type: 'number' }
//       #swagger.parameters['limit'] = { in: 'query', type: 'number' }
//     */
//     branchController.getBranches(req, res);
//   }
// );

// // GET branch by ID (Public)
// router.get(
//   "/:id",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Branches']
//       #swagger.summary = 'Get branch by ID (Public)'
//     */
//     branchController.getBranchById(req, res);
//   }
// );

// // UPDATE branch (Public)
// router.put(
//   "/:id",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Branches']
//       #swagger.summary = 'Update branch (Public)'
//     */
//     branchController.updateBranch(req, res);
//   }
// );

// // DELETE branch (Public)
// router.delete(
//   "/:id",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Branches']
//       #swagger.summary = 'Delete branch (Public)'
//     */
//     branchController.deleteBranch(req, res);
//   }
// );

// module.exports = router;


const express = require("express");
const router = express.Router();
const branchController = require("../controllers/branchController");

/**
 * @swagger
 * tags:
 *   name: Public Branches
 *   description: Public (No Auth) Branch Management APIs (orgId required)
 */


/**
 * ---------------------------------------
 * CREATE Branch (Public)
 * orgId must be sent in body
 * ---------------------------------------
 */
router.post("/create", (req, res) => {
  /*
    #swagger.tags = ['Public Branches']
    #swagger.summary = 'Create branch (Public)'
    #swagger.description = 'Create branch without authentication. orgId is required in body.'

    #swagger.parameters['body'] = {
      in: 'body',
      required: true,
      schema: {
        orgId: "64f5a2d8c9e4b3a1f0a12345",
        branchId: "BR001",
        branchName: "Main Branch",
        branchType: "Urban",
        manager: "65f1c2e4a1b2c3d4e5f67890",
        address: {
          city: "Hyderabad",
          state: "Telangana"
        },
        contact: {
          phone: "9876543210"
        }
      }
    }
  */
  branchController.createBranch(req, res);
});


/**
 * ---------------------------------------
 * GET All Branches (Public)
 * orgId must be sent in query
 * ---------------------------------------
 */
router.get("/", (req, res) => {
  /*
    #swagger.tags = ['Public Branches']
    #swagger.summary = 'Get all branches (Public)'
    #swagger.description = 'Fetch branches by orgId (required)'

    #swagger.parameters['orgId'] = {
      in: 'query',
      required: true,
      type: 'string',
      description: 'Organization ID'
    }

    #swagger.parameters['search'] = { in: 'query', type: 'string' }
    #swagger.parameters['page'] = { in: 'query', type: 'number' }
    #swagger.parameters['limit'] = { in: 'query', type: 'number' }
  */
  branchController.getBranches(req, res);
});


/**
 * ---------------------------------------
 * GET Branch By ID (Public)
 * orgId must be sent in query
 * ---------------------------------------
 */
router.get("/:id", (req, res) => {
  /*
    #swagger.tags = ['Public Branches']
    #swagger.summary = 'Get branch by ID (Public)'
    #swagger.description = 'Fetch single branch by ID. orgId is required in query.'

    #swagger.parameters['orgId'] = {
      in: 'query',
      required: true,
      type: 'string'
    }
  */
  branchController.getBranchById(req, res);
});


/**
 * ---------------------------------------
 * UPDATE Branch (Public)
 * orgId must be sent in body
 * ---------------------------------------
 */
router.put("/:id", (req, res) => {
  /*
    #swagger.tags = ['Public Branches']
    #swagger.summary = 'Update branch (Public)'
    #swagger.description = 'Update branch without authentication. orgId required in body.'

    #swagger.parameters['body'] = {
      in: 'body',
      required: true,
      schema: {
        orgId: "64f5a2d8c9e4b3a1f0a12345",
        branchName: "Updated Branch Name",
        status: "Active"
      }
    }
  */
  branchController.updateBranch(req, res);
});


/**
 * ---------------------------------------
 * DELETE Branch (Public)
 * orgId must be sent in query
 * ---------------------------------------
 */
router.delete("/:id", (req, res) => {
  /*
    #swagger.tags = ['Public Branches']
    #swagger.summary = 'Delete branch (Public)'
    #swagger.description = 'Soft delete branch. orgId required in query.'

    #swagger.parameters['orgId'] = {
      in: 'query',
      required: true,
      type: 'string'
    }
  */
  branchController.deleteBranch(req, res);
});

module.exports = router;
