import { useState, useEffect } from "react"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" 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 { PlayCircle, FileText } from "lucide-react"; export function CombinedTemplate({ resource, isLesson, showMetaTags }) { const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: resource }); 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 (resource && resource?.d) { const nAddress = nip19.naddrEncode({ pubkey: resource.pubkey, kind: resource.kind, identifier: resource.d }); setNAddress(nAddress); } }, [resource]); useEffect(() => { if (zaps.length > 0) { const total = getTotalFromZaps(zaps, resource); setZapAmount(total); } }, [zaps, resource]); const shouldShowMetaTags = (topic) => { if (!showMetaTags) { return !["lesson", "document", "video", "course"].includes(topic); } return true; } if (zapsError) return
Video / Document
{(resource.summary || resource.description)?.split('\n').map((line, index) => ( {line} ))}
{resource?.published_at && resource.published_at !== "" ? ( formatTimestampToHowLongAgo(resource.published_at) ) : ( formatTimestampToHowLongAgo(resource.created_at) )}