/**
 * routes/calendar.routes.js
 *
 * Einbinden in app.js:
 *   const calendarRoutes = require("./routes/calendar.routes");
 *   app.use("/calendar", calendarRoutes);
 */

const express    = require("express");
const router     = express.Router();
const { requireArztOrMitarbeiter } = require("../middleware/auth.middleware");
const ctrl       = require("../controllers/calendar.controller");

// ── Seite ────────────────────────────────────────────────────────────────────
router.get("/", requireArztOrMitarbeiter, ctrl.index);

// ── Appointments API ─────────────────────────────────────────────────────────
router.get( "/api/appointments/:date",    requireArztOrMitarbeiter, ctrl.getAppointments);
router.post("/api/appointments",          requireArztOrMitarbeiter, ctrl.createAppointment);
router.put( "/api/appointments/:id",      requireArztOrMitarbeiter, ctrl.updateAppointment);
router.patch("/api/appointments/:id/status", requireArztOrMitarbeiter, ctrl.patchStatus);
router.delete("/api/appointments/:id",    requireArztOrMitarbeiter, ctrl.deleteAppointment);

// ── Patienten-Suche (Autocomplete) ───────────────────────────────────────────
router.get("/api/patients/search",        requireArztOrMitarbeiter, ctrl.searchPatients);

// ── Feiertage API ─────────────────────────────────────────────────────────────
router.get("/api/holidays/:year",         requireArztOrMitarbeiter, ctrl.getHolidays);

// ── Arzt-Farbe ────────────────────────────────────────────────────────────────
router.patch("/api/doctors/:id/color",    requireArztOrMitarbeiter, ctrl.updateDoctorColor);

module.exports = router;
