diff --git a/app/contact/page.tsx b/app/contact/page.tsx index 40439e7..9bc2456 100644 --- a/app/contact/page.tsx +++ b/app/contact/page.tsx @@ -1,329 +1,277 @@ "use client"; -import { useState, useEffect, useRef, useCallback } from "react"; -import Image from "next/image"; -import Link from "next/link"; -import { usePathname } from "next/navigation"; -import { navLinks } from "@/lib/constants"; +import { useState } from "react"; +import { submitContactForm } from "@/app/actions/email"; +import { + PageHero, + FadeUp, + SectionTitle, + Button, +} from "@/components/ui"; -// Types -type NavLinkType = { - label: string; - href: string; - children?: readonly { label: string; href: string }[]; -}; +const topics = [ + { value: "volunteer", label: "Volunteering with VINdicated" }, + { value: "research", label: "Participating in Research" }, + { value: "story", label: "Sharing My Story" }, + { value: "press", label: "Press & Media" }, + { value: "partnership", label: "Partnership or Collaboration" }, + { value: "grant", label: "Grants & Funding" }, + { value: "general", label: "General Inquiry" }, +]; -export function Nav() { - const [scrolled, setScrolled] = useState(false); - const [menuOpen, setMenuOpen] = useState(false); - const [activeDropdown, setActiveDropdown] = useState(null); - const closeTimer = useRef | null>(null); - const pathname = usePathname(); +const sideInfo = [ + { + cat: "Volunteer", + body: "We have teams for tech, content, design, and operations. If you want to contribute skills to a mission that matters, we'd love to have you.", + }, + { + cat: "Research Participants", + body: "Our correspondence audit studies need testers. Participation is remote, anonymous, and directly contributes to publishable research on automotive discrimination.", + }, + { + cat: "Share Your Story", + body: "Have you experienced discriminatory treatment at a dealership or from a private seller? Your story may contribute to our research or help us better serve our community.", + }, + { + cat: "Press & Media", + body: "For media inquiries about VINdicated or our research, reach out directly. Our founder is available for comment on automotive consumer discrimination.", + }, +]; - const clearCloseTimer = () => { - if (closeTimer.current) { - clearTimeout(closeTimer.current); - closeTimer.current = null; - } - }; - - const closeMenu = useCallback(() => setMenuOpen(false), []); +const inputCls = ` + w-full bg-transparent border-b-2 border-white/20 focus:border-[#ff2d78] outline-none text-white text-[0.95rem] pb-2 transition-colors duration-200 placeholder:text-white/30 +`; - useEffect(() => { - const onScroll = () => setScrolled(window.scrollY > 50); - window.addEventListener("scroll", onScroll, { passive: true }); - return () => window.removeEventListener("scroll", onScroll); - }, []); +function ContactForm() { + const [submitted, setSubmitted] = useState(false); + const [isSubmitting, setIsSubmitting] = useState(false); + const [error, setError] = useState(""); - // Close mobile menu on route change - useEffect(() => { - closeMenu(); - }, [pathname, closeMenu]); + async function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + setIsSubmitting(true); + setError(""); + setSubmitted(false); - // Lock body scroll when menu is open - useEffect(() => { - if (menuOpen) { - document.body.style.overflow = "hidden"; - } else { - document.body.style.overflow = ""; - } - return () => { - document.body.style.overflow = ""; + const form = e.currentTarget; + const formData = new FormData(form); + const data = { + firstName: formData.get("firstName") as string, + lastName: formData.get("lastName") as string, + email: formData.get("email") as string, + topic: formData.get("topic") as string, + message: formData.get("message") as string, }; - }, [menuOpen]); - const isActive = (href: string) => - href === "/" ? pathname === "/" : pathname.startsWith(href); + try { + const res = await submitContactForm(data); + if (res.success) { + setSubmitted(true); + form.reset(); + setTimeout(() => setSubmitted(false), 5000); + } else { + setError(res.error || "Something went wrong."); + } + } catch (err) { + setError("Failed to send message."); + } finally { + setIsSubmitting(false); + } + } return ( - <> - + Message + +