import React, { useEffect, useState } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; import { formatTimestampToHowLongAgo } from "@/utils/time"; import { useImageProxy } from "@/hooks/useImageProxy"; import { getTotalFromZaps } from "@/utils/lightning"; import ZapDisplay from "@/components/zaps/ZapDisplay"; import { Tag } from "primereact/tag"; import { useZapsSubscription } from "@/hooks/nostrQueries/zaps/useZapsSubscription"; const CourseTemplate = ({ course }) => { const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: course }); const [zapAmount, setZapAmount] = useState(0); const router = useRouter(); const { returnImageProxy } = useImageProxy(); useEffect(() => { if (zaps.length > 0) { const total = getTotalFromZaps(zaps, course); setZapAmount(total); } }, [zaps, course]); if (zapsError) return
{course.description || course.summary}
{course.price && course.price > 0 ? (Price: {course.price} sats
) : (Free
)}{course?.published_at && course.published_at !== "" ? ( formatTimestampToHowLongAgo(course.published_at) ) : ( formatTimestampToHowLongAgo(course.created_at) )}