import { useState } from 'react'; import { Link } from 'react-router-dom'; import { nip19 } from 'nostr-tools'; import { ExternalLink, ShieldCheck } from 'lucide-react'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { ProfileBadges } from '@/components/ProfileBadges'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { isSkateSpotsNip05, profileBadges } from '@/lib/badges'; import { useTranslation } from '@/contexts/language'; import { cn } from '@/lib/utils'; /** * A live preview of how the signed-in user appears to everyone else — banner, * avatar, handle, bio and badges — shown at the top of the Edit Profile screen * so "how do I look?" has an answer without leaving the page. * * Reads the same kind-0 metadata the form edits, so it reflects the last SAVED * profile (the form's unsaved edits aren't shown; the sticky Save button commits). */ export function ProfilePreviewCard({ className }: { className?: string }) { const { user, metadata, isLoadingProfile } = useCurrentUser(); const { t } = useTranslation(); const [bannerOk, setBannerOk] = useState(true); if (!user) return null; const name = metadata?.display_name || metadata?.name || ''; const initials = (name || user.pubkey.slice(0, 2)).slice(0, 2).toUpperCase(); const nip05 = metadata?.nip05; const about = metadata?.about?.trim(); const badges = profileBadges(metadata); return (
{/* Banner (falls back to the brand gradient) */}
{metadata?.banner && bannerOk && ( setBannerOk(false)} /> )}
{t('labUi.profilePreview.viewPublic')}
{/* Identity */}
{metadata?.picture && } {initials}

{name || (isLoadingProfile ? t('common.loading') : t('labUi.profilePreview.unnamed'))}

{nip05 ? ( {nip05} ) : ( {t('labUi.profilePreview.noHandle')} )}
{about &&

{about}

} {badges.length > 0 && }
); }