import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { ZapDialog } from '@/components/ZapDialog'; import { useZaps } from '@/hooks/useZaps'; import { useWallet } from '@/hooks/useWallet'; import { cn } from '@/lib/utils'; import { Zap } from 'lucide-react'; import type { Event } from 'nostr-tools'; /** * Crowdfunding progress for an event that declares a `goal` tag (sats). * "Raised" is the live total of NIP-57 zaps to the event, so backers fund it * peer-to-peer โ€” no escrow, no platform in the middle. */ export function FundingGoalCard({ event, goalSats, className, }: { event: Event; goalSats: number; className?: string; }) { const { webln, activeNWC } = useWallet(); const { totalSats, zapCount, isLoading } = useZaps(event, webln, activeNWC); const pct = goalSats > 0 ? Math.min(100, Math.round((totalSats / goalSats) * 100)) : 0; const remaining = Math.max(0, goalSats - totalSats); const reached = remaining === 0; return ( Funding Goal
{isLoading ? 'โ€ฆ' : totalSats.toLocaleString()} / {goalSats.toLocaleString()} sats {pct}%

{reached ? ( <>๐ŸŽ‰ Goal reached! Funded by {zapCount.toLocaleString()} backer{zapCount === 1 ? '' : 's'}. ) : ( <> {remaining.toLocaleString()} sats to go ยท{' '} {zapCount.toLocaleString()} backer{zapCount === 1 ? '' : 's'} )}

); }