import { useState } from "react"; import { updateProfile } from "../api/client"; export default function EditProfileModal({ profile, onClose, onUpdate }) { const [bio, setBio] = useState(profile?.bio || ""); const [website, setWebsite] = useState(profile?.website || ""); const [links, setLinks] = useState(profile?.links || []); const [newLink, setNewLink] = useState(""); const [saving, setSaving] = useState(false); const [error, setError] = useState(null); const handleSubmit = async (e) => { e.preventDefault(); setSaving(true); setError(null); try { await updateProfile({ bio, website, links }); onUpdate(); onClose(); } catch (err) { setError(err.message); } finally { setSaving(false); } }; const addLink = () => { if (!newLink) return; if (!links.includes(newLink)) { setLinks([...links, newLink]); setNewLink(""); setError(null); } }; const removeLink = (index) => { setLinks(links.filter((_, i) => i !== index)); }; return (