const express = require('express');
const {
  getAppointments,
  getAppointment,
  createAppointment,
  updateAppointment,
  cancelAppointment,
  deleteAppointment,
} = require('../controllers/appointmentController');
const { protect } = require('../middleware/auth');
const { requireRole } = require('../middleware/role');

const router = express.Router();

router.use(protect);

router.get('/', getAppointments);
router.get('/:id', getAppointment);

router.post('/', requireRole('receptionist'), createAppointment);
router.put('/:id', requireRole('receptionist'), updateAppointment);
router.patch('/:id/cancel', requireRole('receptionist'), cancelAppointment);
router.delete('/:id', requireRole('receptionist'), deleteAppointment);

module.exports = router;
