const db = require("../db");
const {
  getWaitingPatients
} = require("../services/patient.service");

async function showDashboard(req, res) {
  try {
    const waitingPatients = await getWaitingPatients(db);

    res.render("dashboard", {
      layout: "layout",   // 🔥 DAS FEHLTE

      title: "Dashboard",
      active: "dashboard",
      sidebarPartial: "partials/sidebar",

      waitingPatients,
      user: req.session.user,
      lang: req.session.lang || "de"
    });
  } catch (err) {
    console.error(err);
    res.send("Datenbankfehler");
  }
}

module.exports = {
  showDashboard
};
