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} +
+ )} + +
+ +
+ + +
+

Neuen Nutzer anlegen

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