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 (
{nutzer.name} {nutzer.email ? `(${nutzer.email})` : ""} {nutzer.gesperrt && Gesperrt}