Files

261 lines
11 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useState } from "react";
import Link from "next/link";
import { Check, TrafficCone } from "lucide-react";
import DemoButton from "@/components/ui/DemoButton";
/* ─── shared input styles ─── */
const inputClass =
"w-full rounded-lg px-3 h-11 text-[14px] outline-none focus:ring-2 focus:ring-[var(--accent-yellow)]";
const inputStyle = {
border: "1px solid var(--border-neutral)",
background: "var(--surface)",
color: "var(--text-primary)",
};
const HAZARD_STRIPES =
"repeating-linear-gradient(45deg, #F1B729 0 10px, #171106 10px 20px)";
/* ─── Left column: construction "wird gerade gebaut" panel ─── */
function ConstructionAside() {
return (
<div className="flex flex-col gap-5 w-full" style={{ maxWidth: 460 }}>
<style>{`@keyframes wl-hazard{from{background-position:0 0}to{background-position:28px 0}}@media(prefers-reduced-motion:reduce){.wl-hazard-anim{animation:none!important}}`}</style>
{/* Absperrband */}
<span
className="wl-hazard-anim"
style={{ width: 120, height: 10, borderRadius: 4, background: HAZARD_STRIPES, backgroundSize: "28px 28px", animation: "wl-hazard 1.1s linear infinite" }}
/>
<h1 className="text-[34px] md:text-[46px] font-extrabold leading-[1.08]" style={{ color: "var(--text-primary)", letterSpacing: "-0.02em" }}>
HiveGrid <span style={{ color: "var(--accent-yellow)" }}>wird gerade gebaut.</span>
</h1>
<p className="text-[16px] md:text-[17px] leading-relaxed" style={{ color: "var(--text-secondary)" }}>
Wir legen gerade die letzten Handgriffe an. Trag dich in die Warteliste
ein und sei von Anfang an dabei, wenn HiveGrid für deinen Betrieb startet.
</p>
<div className="flex items-center gap-3 text-[13px] font-medium" style={{ color: "var(--text-tertiary)" }}>
<TrafficCone size={18} strokeWidth={2} style={{ color: "var(--accent-yellow-dark)" }} />
<span>In Arbeit · Start in Kürze. Kein Spam, wir melden uns persönlich.</span>
</div>
{/* heyData DSGVO seal */}
<a
href="https://heydata.eu"
target="_blank"
rel="noopener noreferrer"
title="heyData GDPR seal"
className="mt-2 flex flex-col items-start gap-2"
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
alt="heyData DSGVO-Siegel – DSGVO-konforme Verarbeitung"
src="https://api.heydata.eu/privacy-seal/seal/2cdc4714-a706-4790-975c-7c95935905fe?lang=de&design=design1&sealType=GDPR"
width={96}
height={96}
style={{ border: 0 }}
/>
</a>
</div>
);
}
/* ─── Honeycomb backdrop — just the pattern (no hub, no cards), faded on all
edges AND in the centre so it stays subtle behind the content. ─── */
const HEX_FIELD = (() => {
const r = 33; // hex radius (centre → vertex)
const rr = r - 1.6; // slight inset → thin gaps between combs
const dh2 = (Math.sqrt(3) / 2) * rr;
const h2 = (Math.sqrt(3) / 2) * r;
const colStep = 1.5 * r;
const rowStep = 2 * h2;
const VW = 1600, VH = 1040;
const paths: string[] = [];
for (let col = 0; col * colStep < VW + r; col++) {
const cx = col * colStep;
const yOff = col % 2 ? h2 : 0;
for (let cy = -rowStep + yOff; cy < VH + rowStep; cy += rowStep) {
const f = (n: number) => n.toFixed(1);
paths.push(
`M${f(cx + rr)} ${f(cy)}L${f(cx + rr / 2)} ${f(cy - dh2)}L${f(cx - rr / 2)} ${f(cy - dh2)}L${f(cx - rr)} ${f(cy)}L${f(cx - rr / 2)} ${f(cy + dh2)}L${f(cx + rr / 2)} ${f(cy + dh2)}Z`,
);
}
}
return { paths, VW, VH };
})();
// Ellipse that clears the centre (behind the content) and fades to nothing well
// INSIDE the section box → soft fade on every edge, incl. the bottom seam.
const HC_MASK =
"radial-gradient(82% 70% at 50% 45%, transparent 0%, rgba(0,0,0,0.08) 20%, #000 40%, #000 52%, transparent 76%)";
function HoneycombBackdrop() {
return (
<div
aria-hidden
className="absolute inset-0 pointer-events-none"
style={{ zIndex: 0, WebkitMaskImage: HC_MASK, maskImage: HC_MASK }}
>
<svg className="w-full h-full" viewBox={`0 0 ${HEX_FIELD.VW} ${HEX_FIELD.VH}`} preserveAspectRatio="xMidYMid slice">
{HEX_FIELD.paths.map((d, i) => (
<path key={i} d={d} fill="#F1B729" fillOpacity={0.08} />
))}
</svg>
</div>
);
}
export default function WaitlistForm() {
const [state, setState] = useState<"idle" | "loading" | "ok" | "err">("idle");
const [errMsg, setErrMsg] = useState("");
const [form, setForm] = useState({
vorname: "",
nachname: "",
email: "",
unternehmen: "",
nachricht: "",
dsgvo: false,
});
const update = (k: string, v: string | boolean) =>
setForm((f) => ({ ...f, [k]: v }));
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!form.email || !form.vorname || !form.dsgvo) return;
setState("loading");
setErrMsg("");
try {
const res = await fetch("/api/demo-request", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
firstName: form.vorname,
lastName: form.nachname,
email: form.email,
company: form.unternehmen,
message: form.nachricht,
source: "HiveGrid Warteliste",
}),
});
if (!res.ok) {
const data = await res.json().catch(() => null);
throw new Error(data?.error || "Fehler beim Senden.");
}
setState("ok");
} catch (err) {
setState("err");
setErrMsg(err instanceof Error ? err.message : "Fehler beim Senden.");
}
};
/* ─── Success state ─── */
if (state === "ok") {
return (
<section
className="section-full"
style={{ paddingTop: "var(--hero-top-padding)", paddingBottom: 80, minHeight: "70vh" }}
>
<div className="flex flex-col items-center gap-6 mx-auto text-center" style={{ maxWidth: 560 }}>
<div
className="flex items-center justify-center rounded-full"
style={{ width: 80, height: 80, background: "var(--accent-yellow-light)" }}
>
<Check size={38} style={{ color: "var(--accent-yellow-dark)" }} />
</div>
<h1 className="text-[32px] md:text-[42px] font-bold" style={{ color: "var(--text-primary)" }}>
Du bist auf der Warteliste!
</h1>
<p className="text-[16px] md:text-[18px] leading-relaxed" style={{ color: "var(--text-secondary)" }}>
Wir melden uns bei dir, sobald HiveGrid für deinen Betrieb bereit
ist. Kein Spam, versprochen.
</p>
</div>
</section>
);
}
/* ─── Form ─── */
return (
<section className="section-full" style={{ position: "relative", overflow: "hidden", background: "var(--surface)", paddingTop: "var(--hero-top-padding)", paddingBottom: 80 }}>
<HoneycombBackdrop />
<div className="relative mx-auto" style={{ zIndex: 1, maxWidth: "var(--content-width)" }}>
<div className="flex flex-col lg:flex-row lg:items-center gap-14 lg:gap-20">
{/* ── Left: construction panel ── */}
<div className="lg:flex-1 flex justify-center lg:justify-start">
<ConstructionAside />
</div>
{/* ── Right: form, centered ── */}
<div className="lg:flex-1 flex justify-center">
<form onSubmit={handleSubmit} className="flex flex-col gap-5 w-full" style={{ maxWidth: 460 }}>
{/* Vorname / Nachname */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<label className="flex flex-col gap-1.5">
<span className="text-[13px] font-medium" style={{ color: "var(--text-primary)" }}>Vorname *</span>
<input suppressHydrationWarning required value={form.vorname} onChange={(e) => update("vorname", e.target.value)} className={inputClass} style={inputStyle} />
</label>
<label className="flex flex-col gap-1.5">
<span className="text-[13px] font-medium" style={{ color: "var(--text-primary)" }}>Nachname</span>
<input suppressHydrationWarning value={form.nachname} onChange={(e) => update("nachname", e.target.value)} className={inputClass} style={inputStyle} />
</label>
</div>
{/* E-Mail */}
<label className="flex flex-col gap-1.5">
<span className="text-[13px] font-medium" style={{ color: "var(--text-primary)" }}>E-Mail *</span>
<input suppressHydrationWarning required type="email" value={form.email} onChange={(e) => update("email", e.target.value)} className={inputClass} style={inputStyle} />
</label>
{/* Unternehmen */}
<label className="flex flex-col gap-1.5">
<span className="text-[13px] font-medium" style={{ color: "var(--text-primary)" }}>Unternehmen</span>
<input suppressHydrationWarning value={form.unternehmen} onChange={(e) => update("unternehmen", e.target.value)} className={inputClass} style={inputStyle} />
</label>
{/* Nachricht (optional) */}
<label className="flex flex-col gap-1.5">
<span className="text-[13px] font-medium" style={{ color: "var(--text-primary)" }}>
Nachricht <span style={{ color: "var(--text-tertiary)" }}>(optional)</span>
</span>
<textarea
suppressHydrationWarning
rows={4}
placeholder="Eine Frage oder was dir wichtig ist?"
value={form.nachricht}
onChange={(e) => update("nachricht", e.target.value)}
className="w-full rounded-lg px-3 py-2.5 text-[14px] outline-none resize-y focus:ring-2 focus:ring-[var(--accent-yellow)]"
style={inputStyle}
/>
</label>
{/* DSGVO */}
<label className="flex items-start gap-2.5 cursor-pointer">
<input type="checkbox" checked={form.dsgvo} onChange={(e) => update("dsgvo", e.target.checked)} className="mt-1 shrink-0 accent-[var(--accent-yellow)]" />
<span className="text-[13px] leading-relaxed" style={{ color: "var(--text-secondary)" }}>
Ich stimme der Verarbeitung meiner Daten gemäß der{" "}
<Link href="/datenschutz" className="underline underline-offset-2 hover:no-underline" style={{ color: "var(--accent-yellow)" }}>
Datenschutzerklärung
</Link>{" "}
zu. *
</span>
</label>
{state === "err" && (
<p className="text-[13px] font-medium" style={{ color: "#EF4444" }}>{errMsg}</p>
)}
<DemoButton type="submit" disabled={state === "loading"} fullWidth>
{state === "loading" ? "Sende …" : "Auf die Warteliste"}
</DemoButton>
</form>
</div>
</div>
</div>
</section>
);
}