"use client"; import { useState, type FormEvent, type ReactNode } from "react"; import Link from "next/link"; import Image from "next/image"; import { Reveal } from "./Reveal"; // Same lock icon + copy as /challenge's and /newsletter's EmailCapture — // unified across all newsletter-signup forms instead of each having its // own wording/color for this trust note. function LockIcon() { return ( ); } type NewsletterProps = { title?: ReactNode; description?: string; }; /** * Reused as-is (same bordered/muted panel + icon-decoration + form * pattern) on both Home and /newsletter (the "Impulse & Tipps" page) — * their Figma frames use the exact same newsletter-inner component * instance, just with different copy, so title/description are props * instead of a second near-duplicate component. */ export function Newsletter({ title = <>Starte mit einer Woche voller Klarheit., description = "Melde dich zum Newsletter an und erhalte die 7-Tage-Challenge, mit der du durch mehr Struktur weniger Stress spürst.", }: NewsletterProps = {}) { const [email, setEmail] = useState(""); const [consent, setConsent] = useState(false); const [status, setStatus] = useState<"idle" | "submitting" | "success" | "error">("idle"); const [error, setError] = useState(""); async function handleSubmit(e: FormEvent) { e.preventDefault(); setStatus("submitting"); setError(""); try { const res = await fetch("/api/newsletter/subscribe", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, consent, source: "newsletter-page" }), }); const data = await res.json(); if (!data.ok) { setError(data.reason || "Anmeldung ist fehlgeschlagen. Bitte versuche es später erneut."); setStatus("error"); return; } setStatus("success"); } catch { setError("Anmeldung ist fehlgeschlagen. Bitte versuche es später erneut."); setStatus("error"); } } return (
{/* Outer section padding — same fluid horizontal padding as all other sections */}
{/* Rounded card: cream bg, stacks below md */} {/* Left: copy — fixed width from md+ so the form always gets the remaining space */}
{/* Decorative envelope icon, tilted -4° as per design */}
{/* Heading + body */}

{title}

{description}

{/* Right: form — takes remaining space, centered vertically from md+ */}
{status === "success" ? (

Danke! Du bist jetzt für den Newsletter angemeldet.

) : (
{/* Input + submit button — stacked below md, side by side from md+ */}
setEmail(e.target.value)} placeholder="Deine E-Mail-Adresse" className="flex-1 min-w-0 bg-bg-white border border-border rounded-sm px-6 py-3 text-body text-text-muted font-normal outline-none focus:border-brand transition-colors" />
{/* Consent checkbox — required since this signup's legal basis is consent (email marketing), not the "Ich achte auf deine Daten" trust note alone. Same wording/pattern as NewsletterModal's checkbox. */} {status === "error" && (

{error}

)} {/* Privacy note — same icon/copy/color as the other newsletter forms (see /challenge's EmailCapture). */}

Keine Werbung. Jederzeit abbestellbar.

)}
); }