import { useEffect, useState } from 'react'; import { useAuthStore, type PublicProfile } from '../stores/auth.ts'; interface UserProfileModalProps { userId: string; onClose: () => void; } export function UserProfileModal({ userId, onClose }: UserProfileModalProps) { const getPublicProfile = useAuthStore((s) => s.getPublicProfile); const blockUser = useAuthStore((s) => s.blockUser); const [profile, setProfile] = useState(null); const [error, setError] = useState(null); useEffect(() => { getPublicProfile(userId).then(setProfile).catch(setError); }, [userId, getPublicProfile]); const statusColor = { online: 'bg-gb-green', idle: 'bg-gb-orange', dnd: 'bg-gb-red', offline: 'bg-gb-fg-t', }[profile?.status || 'offline']; return (
e.stopPropagation()}> {error &&
ERR: {error}
} {!profile && !error &&
[loading...]
} {profile && ( <>
{profile.display_name || profile.username}
@{profile.username}
{profile.pronouns &&
{profile.pronouns}
}
{profile.tagline &&
"{profile.tagline}"
} {profile.bio &&
{profile.bio}
} {profile.social_links && profile.social_links.length > 0 && (
{profile.social_links.map((link, idx) => ( {link.platform} ))}
)} {profile.badges && profile.badges.length > 0 && (
{profile.badges.map((badge) => ( {badge.icon && {badge.icon}} {badge.name} ))}
)}
)}
); }