'use client' import { useActionState } from 'react' import Link from 'next/link' import { AlertCircle } from 'lucide-react' import type { VorgangKategorie, VorgangStatus } from '@prisma/client' import { Button } from '@/components/ui/button' import { Checkbox } from '@/components/ui/checkbox' import { Input } from '@/components/ui/input' import { Select } from '@/components/ui/select' import { Textarea } from '@/components/ui/textarea' import { Feld, Feldgruppe } from '@/components/feld' import { Rechtshinweis } from '@/components/rechtshinweis' import { vorgangAendern, vorgangAnlegen } from '@/server/actions/vorgaenge' import { KATEGORIE_BESCHRIFTUNG, PRIORITAET_BESCHRIFTUNG, VORGANG_KATEGORIEN, VORGANG_STATUS, type Formularzustand, } from '@/lib/validierung/vorgaenge' import { GENEHMIGUNG_WARNUNG } from '@/lib/vorgaenge/genehmigungskette' import { VORGANG_STATUS_BESCHRIFTUNG } from '@/lib/vorgaenge/zeitstrahl' /** Date -> "2026-08-22" für . */ function alsFeldwert(datum: Date | null | undefined): string { if (!datum) return '' return datum.toISOString().slice(0, 10) } export type VorgangsFormularWerte = { titel: string kategorie: VorgangKategorie status: VorgangStatus prioritaet: number beschreibung: string | null gegenstelle: string | null aktenzeichen: string | null verantwortlich: string | null naechsterSchritt: string | null faelligAm: Date | null letzterKontaktAm: Date | null genehmigungspflichtig: boolean } export function VorgangsFormular({ modus, betreuteId, vorgangId, vorlageSchluessel, werte, abbrechenHref, }: { modus: 'anlegen' | 'aendern' betreuteId: string vorgangId?: string vorlageSchluessel?: string | null werte: VorgangsFormularWerte abbrechenHref: string }) { const [zustand, aktion, laeuft] = useActionState( modus === 'anlegen' ? vorgangAnlegen : vorgangAendern, {}, ) return (
{vorgangId && } {modus === 'anlegen' && ( )}