"use client" import { useState, type FormEvent, type ReactNode } from "react" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Textarea } from "@/components/ui/textarea" import { SectionReveal } from "@/components/ui/section-reveal" import { Phone, Mail, MapPin, Clock3, ArrowRight, CheckCircle2 } from "lucide-react" import homeData from "@/data/home.json" const iconMap: Record = { phone: , mail: , mappin: , clock: , } export function ContactSection() { const { contact } = homeData const sectionBadge = (contact as any).sectionBadge ?? (contact as any).sectionTag const info = ((contact as any).info ?? ((contact as any).infoItems ?? []).map((item: any) => ({ ...item, icon: String(item.icon ?? "").toLowerCase(), sub: item.sub ?? "", }))) as Array<{ icon: string; label: string; value: string; sub?: string }> const submitLabel = (contact.form as any).submitLabel ?? (contact.form as any).submit const [submitted, setSubmitted] = useState(false) const [isSubmitting, setIsSubmitting] = useState(false) const [errorMessage, setErrorMessage] = useState(null) const handleSubmit = async (e: FormEvent) => { e.preventDefault() const form = e.currentTarget const formData = new FormData(form) setErrorMessage(null) setIsSubmitting(true) try { const response = await fetch("/api/contact", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ name: String(formData.get("name") ?? ""), company: String(formData.get("company") ?? ""), phone: String(formData.get("phone") ?? ""), scale: String(formData.get("scale") ?? ""), message: String(formData.get("message") ?? ""), }), }) const result = (await response.json().catch(() => null)) as { error?: string } | null if (!response.ok) { throw new Error(result?.error ?? "提交失败,请稍后重试。") } form.reset() setSubmitted(true) } catch (error) { setErrorMessage(error instanceof Error ? error.message : "提交失败,请稍后重试。") } finally { setIsSubmitting(false) } } return (
{/* Header */}
{sectionBadge}

{contact.title}

{contact.subtitle}

{/* Left: info */}
{info.map((item) => (
{iconMap[item.icon] ?? iconMap.phone}

{item.label}

{item.value}

{item.sub}

))} {/* Trust note */}

响应时效说明

工作时间内,专属顾问将在{" "} 2 小时内 {" "}联系您;非工作时间提交的信息,将在次一工作日上午统一回复。

{/* Right: form */}
{submitted ? (

信息已提交

管理人员已收到邮件通知,工作时间内 2 小时响应,非工作时间次一工作日上午回复。

) : (

留下信息,先拿一版初步建议