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

/**
 * @swagger
 * tags:
 *   name: Slots
 *   description: Doctor slot management APIs
 */

router.get(
  "/:doctorId",
  authenticate,
  authorize(["admin","superadmin"]),
  (req, res) => {
    /*
      #swagger.tags = ['Slots']
      #swagger.summary = 'Get doctor slots by date'
      #swagger.description = 'Fetch available appointment slots for a doctor on a given date. If slots do not exist, they are generated automatically.'
      #swagger.security = [{ "bearerAuth": [] }]
      #swagger.parameters['doctorId'] = {
        in: 'path',
        required: true,
        type: 'string',
        description: 'Doctor user ID'
      }
    */
    slotController.getDoctorSlots(req, res);
  }
);


router.get("/appointments/:doctorId",authenticate,authorize(["admin", "superadmin"]), (req, res) => {
    /*
      #swagger.tags = ['Slots']
      #swagger.summary = 'Get existing doctor slots by date'
      #swagger.description = 'Fetch existing appointment slots for a doctor on a given date. Does not generate new slots. Applies leave and past-time disabling logic.'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    slotController.getAppointmentSlots(req, res);
  }
);


router.post(
  "/book",
  authenticate,
   authorize(["admin", "receptionist", "doctor", "user"]),
  (req, res) => {
    /*
      #swagger.tags = ['Slots']
      #swagger.summary = 'Book an appointment slot' 
    */
  slotController.bookSlot(req, res);
  }
);
module.exports = router;
