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 { formatTimestampToHowLongAgo } from "@/utils/time"; import { nip19 } from "nostr-tools"; import { Tag } from "primereact/tag"; import { Message } from "primereact/message"; import useWindowWidth from "@/hooks/useWindowWidth"; import GenericButton from "@/components/buttons/GenericButton"; import appConfig from "@/config/appConfig"; export function VideoTemplate({ video }) { const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: video }); const [nAddress, setNAddress] = useState(null); const [zapAmount, setZapAmount] = useState(0); const router = useRouter(); const { returnImageProxy } = useImageProxy(); const windowWidth = useWindowWidth(); const isMobile = windowWidth < 768; useEffect(() => { if (video && video?.id) { const nAddress = nip19.naddrEncode({ pubkey: video.pubkey, kind: video.kind, identifier: video.id, relayUrls: appConfig.defaultRelayUrls }); setNAddress(nAddress); } }, [video]); useEffect(() => { if (zaps.length > 0) { const total = getTotalFromZaps(zaps, video); setZapAmount(total); } }, [zaps, video]); if (zapsError) return
{video?.duration || "5 min"} read
{(video.summary || video.description)?.split('\n').map((line, index) => ( {line} ))}
{video?.published_at && video.published_at !== "" ? ( formatTimestampToHowLongAgo(video.published_at) ) : ( formatTimestampToHowLongAgo(video.created_at) )}