import { NostrEvent, NostrLink } from "@snort/system"; import { FormattedMessage } from "react-intl"; import { Link } from "react-router-dom"; import { findTag } from "@/SnortUtils"; import ProfileImage from "./User/ProfileImage"; import Icon from "@/Icons/Icon"; export function LiveEvent({ ev }: { ev: NostrEvent }) { const title = findTag(ev, "title"); const status = findTag(ev, "status"); const starts = Number(findTag(ev, "starts")); const host = ev.tags.find(a => a[0] === "p" && a[3] === "host")?.[1] ?? ev.pubkey; function statusLine() { switch (status) { case "live": { return (
); } case "ended": { return ( ); } case "planned": { return ( {new Intl.DateTimeFormat(undefined, { dateStyle: "full", timeStyle: "short" }).format( new Date(starts * 1000), )} ); } } } function cta() { const link = `https://zap.stream/${NostrLink.fromEvent(ev).encode()}`; switch (status) { case "live": { return ( ); } case "ended": { if (findTag(ev, "recording")) { return ( ); } } } } return (

{title}

{statusLine()}
{cta()}
); }