"use client" import { useState } from "react" import { useRouter } from "next/navigation" import { toast } from "sonner" export function ProfileForm({ profile }: { profile: any }) { const router = useRouter() const [loading, setLoading] = useState(false) const [error, setError] = useState("") const inputClass = "w-full rounded-lg border border-white/10 bg-white/5 px-4 py-2.5 text-sm text-white placeholder-white/30 outline-none ring-indigo-500 transition focus:border-indigo-500/50 focus:ring-1" const labelClass = "mb-1.5 block text-sm font-medium text-white/70" async function handleSubmit(e: React.FormEvent) { e.preventDefault() setLoading(true) setError("") const formData = new FormData(e.currentTarget) const res = await fetch("/api/profile", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ full_name: formData.get("full_name") as string, phone: (formData.get("phone") as string) || null, company_name: (formData.get("company_name") as string) || null, }), }) setLoading(false) if (!res.ok) { const data = await res.json().catch(() => ({})) setError(typeof data.error === "string" ? data.error : "Failed to save profile") return } toast.success("Profile saved") router.refresh() } return (
{error && (
{error}
)}

Email cannot be changed

) }