const express = require("express");
const router = express.Router();

const { requireLogin } = require("../middleware/auth.middleware");
const {
  listMedications,
  updateMedication,
  toggleMedication,
  showCreateMedication,
  createMedication,
} = require("../controllers/medication.controller");

console.log("✅ medication.routes geladen");

router.get("/", requireLogin, listMedications);

// 🆕 Formular anzeigen
router.get("/create", requireLogin, showCreateMedication);

// 🆕 Speichern
router.post("/create", requireLogin, createMedication);

// 🆕 UPDATE pro Zeile
router.post("/update/:id", requireLogin, updateMedication);

// 🆕 Toggle
router.post("/toggle/:id", requireLogin, toggleMedication);

module.exports = router;
