import "./profile-page.css"; import { useMemo } from "react"; import { useNavigate, useParams } from "react-router-dom"; import * as Tabs from "@radix-ui/react-tabs"; import { NostrPrefix, ParsedZap, encodeTLV, parseNostrLink } from "@snort/system"; import { useUserProfile } from "@snort/system-react"; import { unwrap } from "@snort/shared"; import { FormattedMessage } from "react-intl"; import { Profile } from "@/element/profile"; import { Icon } from "@/element/icon"; import { SendZapsDialog } from "@/element/send-zap"; import { VideoTile } from "@/element/video-tile"; import { FollowButton } from "@/element/follow-button"; import { MuteButton } from "@/element/mute-button"; import { useProfile } from "@/hooks/profile"; import useTopZappers from "@/hooks/top-zappers"; import usePlaceholder from "@/hooks/placeholders"; import { Text } from "@/element/text"; import { StreamState } from "@/index"; import { findTag } from "@/utils"; import { formatSats } from "@/number"; function Zapper({ pubkey, total }: { pubkey: string; total: number }) { return (

{formatSats(total)}

); } function TopZappers({ zaps }: { zaps: ParsedZap[] }) { const zappers = useTopZappers(zaps); return (
{zappers.map(z => ( ))}
); } const defaultBanner = "https://void.cat/d/Hn1AdN5UKmceuDkgDW847q.webp"; export function ProfilePage() { const navigate = useNavigate(); const params = useParams(); const link = parseNostrLink(unwrap(params.npub)); const placeholder = usePlaceholder(link.id); const profile = useUserProfile(link.id); const zapTarget = profile?.lud16 ?? profile?.lud06; const { streams, zaps } = useProfile(link, true); const liveEvent = useMemo(() => { return streams.find(ev => findTag(ev, "status") === StreamState.Live); }, [streams]); const pastStreams = useMemo(() => { return streams.filter(ev => findTag(ev, "status") === StreamState.Ended); }, [streams]); const futureStreams = useMemo(() => { return streams.filter(ev => findTag(ev, "status") === StreamState.Planned); }, [streams]); const isLive = Boolean(liveEvent); function goToLive() { if (liveEvent) { const d = findTag(liveEvent, "d") || ""; const naddr = encodeTLV(NostrPrefix.Address, d, undefined, liveEvent.kind, liveEvent.pubkey); navigate(`/${naddr}`); } } return (
{profile?.name
{profile?.picture ? ( {profile.name ) : ( {profile?.name )}
{isLive ? (
) : ( )}
{zapTarget && (
} targetName={profile?.name || link.id} /> )}
{profile?.name &&

{profile.name}

} {profile?.about && (

)}
{pastStreams.map(ev => (
))}
{futureStreams.map(ev => (
))}
); }