"use client"; import { useState, useTransition } from "react"; import { speichereFirmaEinstellungen } from "@/app/firma/actions"; import { Alert } from "@/components/ui/Alert"; import { Button } from "@/components/ui/Button"; import { FIELD_CLASSES, FormField } from "@/components/ui/FormField"; import { STANDARD_FARBE_DUNKEL, STANDARD_FARBE_PRIMAER } from "@/lib/firma/farben"; import type { Firma } from "@/lib/firma/queries"; export function FirmaEinstellungenForm({ firma }: { firma: Firma }) { const [fehler, setFehler] = useState(null); const [gespeichert, setGespeichert] = useState(false); const [standard, setStandard] = useState(!firma.farbe_primaer && !firma.farbe_dunkel); const [isPending, startTransition] = useTransition(); function handleSubmit(event: React.FormEvent) { event.preventDefault(); const formData = new FormData(event.currentTarget); startTransition(async () => { const ergebnis = await speichereFirmaEinstellungen(formData); setGespeichert(ergebnis.success); setFehler(ergebnis.success ? null : ergebnis.error); }); } return (
{fehler && (
{fehler}
)} {!standard && (
)}

Beide Farben brauchen genug Kontrast zu weißer Schrift (mindestens 4,5:1).

{gespeichert && (

Gespeichert.

)}
); }