import { z } from "zod" // Shared between the server action and the form so both validate identically. export const contactSchema = z.object({ name: z .string() .trim() .min(2, "Bitte gib deinen Namen an."), email: z .string() .trim() .pipe(z.email("Bitte gib eine gültige E-Mail-Adresse an.")), company: z.string().trim().max(120, "Maximal 120 Zeichen.").optional(), message: z .string() .trim() .min(20, "Erzähl uns in mindestens 20 Zeichen, worum es geht.") .max(4000, "Maximal 4000 Zeichen."), privacy: z.literal("on", { error: "Bitte stimme der Verarbeitung deiner Angaben zu.", }), }) export type ContactInput = z.infer export type ContactField = keyof ContactInput export type ContactFormState = { status: "idle" | "success" | "error" message?: string fieldErrors?: Partial> // Echoed back so the form keeps its values after a failed submit values?: Partial> } export const initialContactState: ContactFormState = { status: "idle" }