import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { aktualisiereAuftrag } from "./actions"; import { listFahrzeuge, listOrte, loadAuftrag } from "@/lib/auftraege/queries"; import { loadProfile } from "@/lib/auth/profile"; import { kannAuftraegeVerwalten } from "@/lib/auth/roles"; import { istBearbeitbar, NICHT_BEARBEITBAR_MELDUNG } from "@/lib/auftraege/validate-auftrag"; import { alsDatetimeLocal, berechneVorbefuelltenZeitpunkt } from "@/lib/auftraege/zeitplanung"; import { AuftragStammFelder } from "@/components/auftraege/AuftragStammFelder"; import { NetzSicheresFormular } from "@/components/pwa/NetzSicheresFormular"; import { Card } from "@/components/ui/Card"; import { Button, buttonClasses } from "@/components/ui/Button"; import { Alert } from "@/components/ui/Alert"; export default async function AuftragBearbeitenPage({ params, searchParams, }: { params: Promise<{ id: string }>; searchParams: Promise<{ error?: string }>; }) { const { id } = await params; const { error } = await searchParams; const profileResult = await loadProfile(); if (profileResult.status !== "ok" || !kannAuftraegeVerwalten(profileResult.profile.role)) { redirect(`/auftraege/${id}?error=${encodeURIComponent("Nur Disponent/Admin duerfen Auftraege bearbeiten.")}`); } const [auftrag, orte, fahrzeuge] = await Promise.all([loadAuftrag(id), listOrte(), listFahrzeuge()]); if (!auftrag) { notFound(); } if (!istBearbeitbar(auftrag.status)) { redirect(`/auftraege/${id}?error=${encodeURIComponent(NICHT_BEARBEITBAR_MELDUNG)}`); } const aktion = aktualisiereAuftrag.bind(null, auftrag.id); return (

Auftrag bearbeiten

{auftrag.auftragsnummer}

{error && (
{error}
)}
Abbrechen
); }