"use client"; import { useState } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { motion, AnimatePresence } from "framer-motion"; import { toast } from "sonner"; export default function RequestPage() { const router = useRouter(); const searchParams = useSearchParams(); const prefillType = searchParams.get("type") as RequestType | null; const [step, setStep] = useState(1); const [loading, setLoading] = useState(false); const [form, setForm] = useState({ type: prefillType || "", name: "", email: "", domain: "", company: "", message: "", hosting: "", concern: "", }); type RequestType = | "audit" | "consultation" | "support" | "tool" | "partnership"; const requestTypes: { id: RequestType; label: string; desc: string; icon: string }[] = [ { id: "audit", label: "Free Audit", desc: "Request a free website, DNS or performance check.", icon: "🧠", }, { id: "consultation", label: "Consultation / Quote", desc: "Discuss a project, hosting setup, or optimization.", icon: "⚙️", }, { id: "support", label: "Technical Support", desc: "Report an issue or request hands-on help.", icon: "🛠️", }, { id: "tool", label: "Tool Follow-Up", desc: "Continue from one of our free tools or reports.", icon: "📊", }, { id: "partnership", label: "Partnership / Collaboration", desc: "Discuss a potential collaboration or integration.", icon: "🤝", }, ]; const handleChange = (e: React.ChangeEvent) => { const { name, value } = e.target; setForm((f) => ({ ...f, [name]: value })); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); try { const res = await fetch("/api/request", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(form), }); if (!res.ok) throw new Error("Submission failed"); toast.success("Request submitted successfully!"); router.push("/request/success"); } catch (err) { console.error(err); toast.error("Something went wrong. Please try again."); } finally { setLoading(false); } }; return (

Start a Request

Choose what you’d like to do — audits, consultations, or support. We’ll guide you through the right steps and get back within one business day.

{/* Step 1 – Select Request Type */} {step === 1 && (

What kind of request do you have?

{requestTypes.map((t) => ( ))}
)} {/* Step 2 – Request Form */} {step === 2 && (

{requestTypes.find((t) => t.id === form.type)?.label}

{/* Show domain and technical fields only for audits / consultations */} {(form.type === "audit" || form.type === "consultation") && ( <>
)}