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

/**
 * @swagger
 * tags:
 *   name: Public Slots
 *   description: Public (No Auth) Doctor slot APIs
 */

// GET doctor slots (Public)
router.get(
  "/:doctorId",
  (req, res) => {
    /*
      #swagger.tags = ['Public Slots']
      #swagger.summary = 'Get doctor slots by date (Public)'
      #swagger.description = 'Fetch available appointment slots for a doctor without authentication. orgId is required in query.'

      #swagger.parameters['doctorId'] = {
        in: 'path',
        required: true,
        type: 'string',
        description: 'Doctor user ID'
      }

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

      #swagger.parameters['date'] = {
        in: 'query',
        required: false,
        type: 'string',
        description: 'Appointment date (YYYY-MM-DD)'
      }
    */
    slotController.getDoctorSlots(req, res);
  }
);

// BOOK slot (Public)
router.post(
  "/book",
  (req, res) => {
    /*
      #swagger.tags = ['Public Slots']
      #swagger.summary = 'Book appointment slot (Public)'
      #swagger.description = 'Book a doctor slot without authentication'
      #swagger.parameters['body'] = {
        in: 'body',
        required: true,
        schema: {
          doctorId: "64f5a2d8c9e4b3a1f0a12345",
          date: "2026-02-20",
          time: "10:30 AM",
          patientName: "John Doe"
        }
      }
    */
    slotController.bookSlot(req, res);
  }
);

module.exports = router;
