'use client' import { useActionState } from 'react' import { useFormStatus } from 'react-dom' import { AlertCircle } from 'lucide-react' import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' import { Button } from '@/components/ui/button' 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 { KONTAKT_ANREDEN, KONTAKT_ROLLEN, KONTAKT_ROLLE_BESCHRIFTUNG, } from '@/lib/validierung/kontakte' import { ANREDE_BESCHRIFTUNG } from '@/lib/kontakte/anrede' import { kontaktSpeichern, type KontaktZustand } from '@/server/actions/kontakte' /** * Formular fuer einen Kontakt - Behoerde, Heim, Arzt, Notar. * * Das Aktenzeichen steht bewusst gleich neben dem Namen: Am Telefon ist * es das Erste, wonach gefragt wird. */ export type KontaktWerte = { id: string name: string organisation: string | null rolle: string anrede: string telefon: string | null mobil: string | null fax: string | null email: string | null strasse: string | null plz: string | null ort: string | null aktenzeichen: string | null notizen: string | null } const ANFANG: KontaktZustand = {} export function KontaktFormular({ betreuteId, kontakt, }: { betreuteId: string kontakt?: KontaktWerte }) { const [zustand, aktion] = useActionState(kontaktSpeichern, ANFANG) const wert = (feld: keyof KontaktWerte): string => zustand.werte?.[feld] ?? (kontakt ? (kontakt[feld] ?? '') : '') return (
{kontakt && } {zustand.fehler && ( )}