import { useState, useEffect } from "react"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" import { PlayCircle } from "lucide-react" import ZapDisplay from "@/components/zaps/ZapDisplay"; import Image from "next/image" import { useZapsSubscription } from "@/hooks/nostrQueries/zaps/useZapsSubscription"; import { getTotalFromZaps } from "@/utils/lightning"; import { useImageProxy } from "@/hooks/useImageProxy"; import { useRouter } from "next/router"; import { nip19 } from "nostr-tools"; import { formatTimestampToHowLongAgo } from "@/utils/time"; import { Tag } from "primereact/tag"; import GenericButton from "@/components/buttons/GenericButton"; export function VideoTemplate({ video }) { const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: video }); const [zapAmount, setZapAmount] = useState(0); const [nAddress, setNAddress] = useState(null); const router = useRouter(); const { returnImageProxy } = useImageProxy(); useEffect(() => { const addr = nip19.naddrEncode({ pubkey: video.pubkey, kind: video.kind, identifier: video.id }) setNAddress(addr); }, [video]); useEffect(() => { if (zaps.length > 0) { const total = getTotalFromZaps(zaps, video); setZapAmount(total); } }, [zaps, video]); if (zapsError) return
{video?.published_at && video.published_at !== "" ? ( formatTimestampToHowLongAgo(video.published_at) ) : ( formatTimestampToHowLongAgo(video.created_at) )}