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

/**
 * @swagger
 * tags:
 *   name: Public Appointments
 *   description: Public (No Auth) Appointment APIs
 */

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

// GET all appointments (Public)
router.get(
  "/",
  (req, res) => {
    /*
      #swagger.tags = ['Public Appointments']
      #swagger.summary = 'Get all appointments (Public)'
    */
    appointmentController.getAllAppointments(req, res);
  }
);

// UPDATE appointment (Public)
router.put(
  "/update/:id",
  (req, res) => {
    /*
      #swagger.tags = ['Public Appointments']
      #swagger.summary = 'Update appointment (Public)'
      #swagger.parameters['id'] = {
        in: 'path',
        required: true,
        type: 'string',
        example: '68f2a9c1c3a0a123456789ef'
      }
    */
    appointmentController.updateAppointment(req, res);
  }
);

// MARK VISITED (Public)
router.put(
  "/visited/:id",
  (req, res) => {
    /*
      #swagger.tags = ['Public Appointments']
      #swagger.summary = 'Mark appointment as visited (Public)'
      #swagger.parameters['id'] = {
        in: 'path',
        required: true,
        type: 'string',
        example: '68f2a9c1c3a0a123456789ef'
      }
    */
    appointmentController.markAsVisited(req, res);
  }
);

// GET single appointment
router.get(
  "/:id",
  (req, res) => {
    /*
      #swagger.tags = ['Public Appointments']
      #swagger.summary = 'Get single appointment by ID (Public)'
    */
    appointmentController.getSingleAppointment(req, res);
  }
);

// CANCEL appointment
router.put(
  "/cancel/:id",
  (req, res) => {
    /*
      #swagger.tags = ['Public Appointments']
      #swagger.summary = 'Cancel appointment (Public)'
    */
    appointmentController.cancelAppointment(req, res);
  }
);

module.exports = router;
