"use client"; import { useState } from "react"; export default function ProfileForm({ user }: { user: { id: string; name: string; email: string } }) { const [name, setName] = useState(user.name); const [saved, setSaved] = useState(false); const [loading, setLoading] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); await fetch("/api/user/profile", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name }), }); setSaved(true); setLoading(false); setTimeout(() => setSaved(false), 3000); } return (

اطلاعات حساب

setName(e.target.value)} className="w-full border rounded-xl px-4 py-2.5 focus:outline-none focus:ring-2 focus:ring-green-500" />
{saved &&

✓ ذخیره شد

}
); }