From 8ed4c86813aa1b5b7d975ba90405498537d91380 Mon Sep 17 00:00:00 2001 From: Jonny Date: Wed, 15 Jul 2026 11:43:26 +0200 Subject: [PATCH] feat: add Nutzerverwaltung page --- web/app/nutzerverwaltung/page.tsx | 111 ++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 web/app/nutzerverwaltung/page.tsx diff --git a/web/app/nutzerverwaltung/page.tsx b/web/app/nutzerverwaltung/page.tsx new file mode 100644 index 0000000..ed7fbd6 --- /dev/null +++ b/web/app/nutzerverwaltung/page.tsx @@ -0,0 +1,111 @@ +import { redirect } from "next/navigation"; +import { loadProfile } from "@/lib/auth/profile"; +import { canManageUsers } from "@/lib/auth/roles"; +import { listNutzer } from "@/lib/nutzerverwaltung/queries"; +import { erstelleNutzer, aendereRolle, sperreNutzer, entsperreNutzer } from "./actions"; +import { Card } from "@/components/ui/Card"; +import { Button } from "@/components/ui/Button"; +import { Alert } from "@/components/ui/Alert"; +import { FormField, FIELD_CLASSES } from "@/components/ui/FormField"; + +const ROLLEN_OPTIONEN = ["admin", "disponent", "fahrer", "readonly"] as const; + +export default async function NutzerverwaltungPage({ + searchParams, +}: { + searchParams: Promise<{ error?: string }>; +}) { + const profileResult = await loadProfile(); + if (profileResult.status !== "ok" || !canManageUsers(profileResult.profile.role)) { + redirect(`/auftraege?error=${encodeURIComponent("Nur Admin darf die Nutzerverwaltung nutzen.")}`); + } + + const { error } = await searchParams; + const nutzerListe = await listNutzer(); + + return ( +
+

Nutzerverwaltung

+ + {error && ( +
+ {error} +
+ )} + +
+
    + {nutzerListe.map((nutzer) => { + const istEigenerAccount = nutzer.id === profileResult.profile.id; + const aendereRolleAction = aendereRolle.bind(null, nutzer.id); + const sperrenAction = sperreNutzer.bind(null, nutzer.id); + const entsperrenAction = entsperreNutzer.bind(null, nutzer.id); + + return ( +
  • + +

    + {nutzer.name} {nutzer.email ? `(${nutzer.email})` : ""} + {nutzer.gesperrt && Gesperrt} +

    +
    + + +
    +
    + +
    +
    +
  • + ); + })} +
+
+ + +
+

Neuen Nutzer anlegen

+ + + + + + + + + + + + + +
+
+
+ ); +}