import React, { useEffect, useState } from "react"; import { Tag } from "primereact/tag"; import Image from "next/image"; import ZapDisplay from "@/components/zaps/ZapDisplay"; import { useImageProxy } from "@/hooks/useImageProxy"; import GenericButton from "@/components/buttons/GenericButton"; import { useZapsQuery } from "@/hooks/nostrQueries/zaps/useZapsQuery"; import { nip19 } from "nostr-tools"; import { getTotalFromZaps } from "@/utils/lightning"; import dynamic from "next/dynamic"; import { Divider } from "primereact/divider"; const MDDisplay = dynamic( () => import("@uiw/react-markdown-preview"), { ssr: false, } ); const VideoLesson = ({ lesson, course, decryptionPerformed, isPaid }) => { const [zapAmount, setZapAmount] = useState(0); const [nAddress, setNAddress] = useState(null); const { zaps, zapsLoading, zapsError } = useZapsQuery({ event: lesson, type: "lesson" }); const { returnImageProxy } = useImageProxy(); useEffect(() => { if (!zaps || zapsLoading || zapsError) return; const total = getTotalFromZaps(zaps, lesson); setZapAmount(total); }, [zaps, zapsLoading, zapsError, lesson]); useEffect(() => { const addr = nip19.naddrEncode({ pubkey: lesson.pubkey, kind: lesson.kind, identifier: lesson.d, }); setNAddress(addr); }, [lesson]); const renderContent = () => { if (isPaid && decryptionPerformed) { return ( <>
This content is paid and needs to be purchased before viewing.
{lesson.summary}