diff --git a/client/pages/Dashboard.tsx b/client/pages/Dashboard.tsx index 63fed210..1342fdfe 100644 --- a/client/pages/Dashboard.tsx +++ b/client/pages/Dashboard.tsx @@ -49,6 +49,14 @@ import { export default function Dashboard() { const navigate = useNavigate(); const { user, profile, loading: authLoading, updateProfile } = useAuth(); + const [displayName, setDisplayName] = useState(""); + const [locationInput, setLocationInput] = useState(""); + const [bio, setBio] = useState(""); + const [website, setWebsite] = useState(""); + const [linkedin, setLinkedin] = useState(""); + const [github, setGithub] = useState(""); + const [twitter, setTwitter] = useState(""); + const [savingProfile, setSavingProfile] = useState(false); const [isLoading, setIsLoading] = useState(true); const [projects, setProjects] = useState([]); const [achievements, setAchievements] = useState([]); @@ -89,6 +97,35 @@ export default function Dashboard() { } }, [user, profile, authLoading, navigate]); + // Sync local settings form with profile + useEffect(() => { + setDisplayName(profile?.full_name || ""); + setLocationInput(profile?.location || ""); + setBio(profile?.bio || ""); + setWebsite((profile as any)?.website_url || ""); + setLinkedin(profile?.linkedin_url || ""); + setGithub(profile?.github_url || ""); + setTwitter(profile?.twitter_url || ""); + }, [profile]); + + const saveProfile = async () => { + if (!user) return; + setSavingProfile(true); + try { + await updateProfile({ + full_name: displayName, + location: locationInput, + bio, + website_url: website as any, + linkedin_url: linkedin, + github_url: github, + twitter_url: twitter, + } as any); + } finally { + setSavingProfile(false); + } + }; + const loadDashboardData = async () => { try { setIsLoading(true); @@ -499,33 +536,38 @@ export default function Dashboard() {