import React, { useEffect, useState } from "react"; import apiclient from "../apiclient"; import type { GetMyProfileData } from "../apiclient/data-contracts"; import { useUser } from "@stackframe/react"; import { useNavigate } from "react-router-dom"; import { toast } from "sonner"; export interface Props {} export const ProfileCard: React.FC = () => { const user = useUser(); const navigate = useNavigate(); const [loading, setLoading] = useState(false); const [profile, setProfile] = useState(null); const [error, setError] = useState(null); useEffect(() => { const load = async () => { if (!user) return; // not signed in yet setLoading(true); setError(null); try { const res = await apiclient.get_my_profile(); const data = await res.json(); setProfile(data); } catch (e: any) { setError("Failed to load profile"); } finally { setLoading(false); } }; load(); }, [user?.id]); if (!user) { return (

Sign in to manage your profile.

); } return (

Your Profile

{loading && Loading…}
{error &&

{error}

}
{profile && (

User ID: {profile.user_id}

)}
); };