import "./profile-page.css"; import { useMemo } from "react"; import moment from "moment"; import { useNavigate, useParams } from "react-router-dom"; import * as Tabs from "@radix-ui/react-tabs"; import { parseNostrLink, NostrPrefix, ParsedZap, encodeTLV, } from "@snort/system"; import { useUserProfile } from "@snort/system-react"; 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, System } 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(params.npub!); const placeholder = usePlaceholder(link.id); const profile = useUserProfile(System, 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 ? (
live
) : ( offline )}
{zapTarget && (
Zap
} targetName={profile?.name || link.id} /> )}
{profile?.name &&

{profile.name}

} {profile?.about && (

)}
Top Zappers
Past Streams
Schedule
{pastStreams.map((ev) => (
Streamed on{" "} {moment(Number(ev.created_at) * 1000).format( "MMM DD, YYYY" )}
))}
{futureStreams.map((ev) => (
Scheduled for{" "} {moment(Number(ev.created_at) * 1000).format( "MMM DD, YYYY h:mm:ss a" )}
))}
); }