import "./ZapGoal.css"; import { NostrEvent, NostrLink } from "@snort/system"; import { useState } from "react"; import { FormattedNumber } from "react-intl"; import Icon from "@/Components/Icons/Icon"; import Progress from "@/Components/Progress/Progress"; import ZapModal from "@/Components/ZapModal/ZapModal"; import useZapsFeed from "@/Feed/ZapsFeed"; import { findTag } from "@/Utils"; import { formatShort } from "@/Utils/Number"; import { Zapper } from "@/Utils/Zapper"; export function ZapGoal({ ev }: { ev: NostrEvent }) { const [zap, setZap] = useState(false); const zaps = useZapsFeed(NostrLink.fromEvent(ev)); const target = Number(findTag(ev, "amount")); const amount = zaps.reduce((acc, v) => (acc += v.amount * 1000), 0); const progress = amount / target; return (

{ev.content}

setZap(true)}>
setZap(false)} />
{formatShort(amount / 1000)}/{formatShort(target / 1000)}
); }