"use client"; import { useState, type FormEvent } from "react"; import { track } from "@/lib/analytics/client"; import { TextField, TextAreaField } from "@/components/FormField"; type ContactFormProps = { toEmail: string; subjectPrefix?: string; submitLabel?: string; }; /** * Opens the visitor's email client with a pre-filled message. There is no * backend configured yet — swap this for a Server Action once a mail * provider is connected. */ export function ContactForm({ toEmail, subjectPrefix = "Nachricht über anouma.org", submitLabel = "Nachricht senden", }: ContactFormProps) { const [sent, setSent] = useState(false); function handleSubmit(e: FormEvent) { e.preventDefault(); const data = new FormData(e.currentTarget); const name = String(data.get("name") ?? ""); const email = String(data.get("email") ?? ""); const message = String(data.get("message") ?? ""); const subject = encodeURIComponent(`${subjectPrefix} von ${name}`); const body = encodeURIComponent(`${message}\n\n– ${name} (${email})`); window.location.href = `mailto:${toEmail}?subject=${subject}&body=${body}`; // Event only — never the form's name/email/message content, see // lib/analytics/events.ts and the data-minimization requirement. track("contact_clicked"); setSent(true); } return (
{sent && (

Dein E-Mail-Programm sollte sich jetzt geöffnet haben. Falls nicht, schreib gerne direkt an{" "} {toEmail}.

)} ); }