{lessonCount} lessons
-{course?.published_at && course.published_at !== "" ? ( - formatTimestampToHowLongAgo(course.published_at) - ) : ( - formatTimestampToHowLongAgo(course.created_at) - )}
-{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) - )} -
-{lessonCount} lessons
+{line}
+ ))} +{line}
+ ))} +{course?.published_at && course.published_at !== "" ? ( + formatTimestampToHowLongAgo(course.published_at) + ) : ( + formatTimestampToHowLongAgo(course.created_at) + )}
+{line}
+ ))} +{line}
+ ))} +{document?.published_at && document.published_at !== "" ? ( diff --git a/src/components/content/carousels/templates/ResourceTemplate.js b/src/components/content/carousels/templates/ResourceTemplate.js deleted file mode 100644 index fa7324d..0000000 --- a/src/components/content/carousels/templates/ResourceTemplate.js +++ /dev/null @@ -1,78 +0,0 @@ -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 { Tag } from "primereact/tag"; -import ZapDisplay from "@/components/zaps/ZapDisplay"; -import { useZapsSubscription } from "@/hooks/nostrQueries/zaps/useZapsSubscription"; - -const ResourceTemplate = ({ resource }) => { - const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: resource }); - const [zapAmount, setZapAmount] = useState(0); - - const router = useRouter(); - const { returnImageProxy } = useImageProxy(); - - useEffect(() => { - if (zaps.length > 0) { - const total = getTotalFromZaps(zaps, resource); - setZapAmount(total); - } - }, [zaps, resource]); - - if (zapsError) return
{resource.summary}
- {resource.price && resource.price > 0 ? ( -Price: {resource.price} sats
- ) : ( -Free
- )} -- {formatTimestampToHowLongAgo(resource.published_at)} -
-{line}
+ ))} +{line}
+ ))} +{video?.published_at && video.published_at !== "" ? ( diff --git a/src/components/content/carousels/templates/WorkshopTemplate.js b/src/components/content/carousels/templates/WorkshopTemplate.js deleted file mode 100644 index 3ff425d..0000000 --- a/src/components/content/carousels/templates/WorkshopTemplate.js +++ /dev/null @@ -1,74 +0,0 @@ -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 { useZapsSubscription } from "@/hooks/nostrQueries/zaps/useZapsSubscription"; -import ZapDisplay from "@/components/zaps/ZapDisplay"; -import { Tag } from "primereact/tag"; - -const WorkshopTemplate = ({ workshop }) => { - const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: workshop }); - const [zapAmount, setZapAmount] = useState(0); - const router = useRouter(); - const { returnImageProxy } = useImageProxy(); - - useEffect(() => { - if (zaps.length > 0) { - const total = getTotalFromZaps(zaps, workshop); - setZapAmount(total); - } - }, [zaps, workshop]); - - if (zapsError) return
{workshop.summary}
- {workshop.price && workshop.price > 0 ? ( -Price: {workshop.price} sats
- ) : ( -Free
- )} -- {formatTimestampToHowLongAgo(workshop.published_at)} -
-{lesson?.summary}
+{lesson?.summary && ( +
{line}
+ ))} +{lesson.summary}
+{lesson.summary && ( +
{line}
+ ))} +{lesson?.summary}
+{lesson?.summary && ( +
{line}
+ ))} +{lesson.summary}
+{lesson.summary && ( +
{line}
+ ))} +{summary}
+{summary && ( +
{line}
+ ))} +{line}
+ ))} +{summary}
+{summary && ( +
{line}
+ ))} +Paid Workshop
+Paid Video
Paid Workshop
+Paid Video
Courses
Workshops
+Videos
Resources
diff --git a/src/hooks/nostr/useWorkshops.js b/src/hooks/nostr/useVideos.js similarity index 53% rename from src/hooks/nostr/useWorkshops.js rename to src/hooks/nostr/useVideos.js index 5d01b04..e1c119d 100644 --- a/src/hooks/nostr/useWorkshops.js +++ b/src/hooks/nostr/useVideos.js @@ -4,12 +4,12 @@ import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery'; const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY; -export function useWorkshops() { +export function useVideos() { const [isClient, setIsClient] = useState(false); - const [workshops, setWorkshops] = useState(); + const [videos, setVideos] = useState(); // Add new state variables for loading and error - const [workshopsLoading, setWorkshopsLoading] = useState(false); - const [workshopsError, setWorkshopsError] = useState(null); + const [videosLoading, setVideosLoading] = useState(false); + const [videosError, setVideosError] = useState(null); const { contentIds } = useContentIdsQuery() const {ndk, addSigner} = useNDKContext(); @@ -19,18 +19,18 @@ export function useWorkshops() { }, []); const hasRequiredProperties = (event, contentIds) => { - const hasWorkshop = event.tags.some(([tag, value]) => tag === "t" && value === "workshop"); + const hasVideo = event.tags.some(([tag, value]) => tag === "t" && value === "video"); const hasId = event.tags.some(([tag, value]) => tag === "d" && contentIds.includes(value)); - return hasWorkshop && hasId; + return hasVideo && hasId; }; - const fetchWorkshopsFromNDK = async () => { - setWorkshopsLoading(true); - setWorkshopsError(null); + const fetchVideosFromNDK = async () => { + setVideosLoading(true); + setVideosError(null); try { if (!contentIds || contentIds.length === 0) { console.log('No content IDs found'); - setWorkshopsLoading(false); + setVideosLoading(false); return []; // Return early if no content IDs are found } @@ -41,30 +41,30 @@ export function useWorkshops() { if (events && events.size > 0) { const eventsArray = Array.from(events); - const workshops = eventsArray.filter(event => hasRequiredProperties(event, contentIds)); - setWorkshopsLoading(false); - return workshops; + const videos = eventsArray.filter(event => hasRequiredProperties(event, contentIds)); + setVideosLoading(false); + return videos; } - setWorkshopsLoading(false); + setVideosLoading(false); return []; } catch (error) { - console.error('Error fetching workshops from NDK:', error); - setWorkshopsError(error); - setWorkshopsLoading(false); + console.error('Error fetching videos from NDK:', error); + setVideosError(error); + setVideosLoading(false); return []; } }; useEffect(() => { if (isClient && contentIds) { - fetchWorkshopsFromNDK().then(fetchedWorkshops => { - if (fetchedWorkshops && fetchedWorkshops.length > 0) { - console.log('fetchedworkshops', fetchedWorkshops) - setWorkshops(fetchedWorkshops); + fetchVideosFromNDK().then(fetchedVideos => { + if (fetchedVideos && fetchedVideos.length > 0) { + console.log('fetchedvideos', fetchedVideos) + setVideos(fetchedVideos); } }); } }, [isClient, contentIds]); - return { workshops, workshopsLoading, workshopsError }; + return { videos, videosLoading, videosError }; } \ No newline at end of file diff --git a/src/hooks/nostrQueries/content/useAllContentQuery.js b/src/hooks/nostrQueries/content/useAllContentQuery.js index 1526d07..6fc8597 100644 --- a/src/hooks/nostrQueries/content/useAllContentQuery.js +++ b/src/hooks/nostrQueries/content/useAllContentQuery.js @@ -24,7 +24,7 @@ const fetchAllContentFromNDK = async (ids) => { } return []; } catch (error) { - console.error('Error fetching workshops from NDK:', error); + console.error('Error fetching videos from NDK:', error); return []; } }; diff --git a/src/hooks/nostrQueries/content/useWorkshopsQuery.js b/src/hooks/nostrQueries/content/useVideosQuery.js similarity index 66% rename from src/hooks/nostrQueries/content/useWorkshopsQuery.js rename to src/hooks/nostrQueries/content/useVideosQuery.js index 13bd444..2ea60be 100644 --- a/src/hooks/nostrQueries/content/useWorkshopsQuery.js +++ b/src/hooks/nostrQueries/content/useVideosQuery.js @@ -5,7 +5,7 @@ import axios from 'axios'; const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY; -export function useWorkshopsQuery() { +export function useVideosQuery() { const [isClient, setIsClient] = useState(false); const {ndk, addSigner} = useNDKContext(); @@ -14,12 +14,12 @@ export function useWorkshopsQuery() { }, []); const hasRequiredProperties = (event, contentIds) => { - const hasWorkshop = event.tags.some(([tag, value]) => tag === "t" && value === "workshop"); + const hasVideo = event.tags.some(([tag, value]) => tag === "t" && value === "video"); const hasId = event.tags.some(([tag, value]) => tag === "d" && contentIds.includes(value)); - return hasWorkshop && hasId; + return hasVideo && hasId; }; - const fetchWorkshopsFromNDK = async () => { + const fetchVideosFromNDK = async () => { try { const response = await axios.get(`/api/content/all`); const contentIds = response.data; @@ -36,23 +36,23 @@ export function useWorkshopsQuery() { if (events && events.size > 0) { const eventsArray = Array.from(events); - const workshops = eventsArray.filter(event => hasRequiredProperties(event, contentIds)); - return workshops; + const videos = eventsArray.filter(event => hasRequiredProperties(event, contentIds)); + return videos; } return []; } catch (error) { - console.error('Error fetching workshops from NDK:', error); + console.error('Error fetching videos from NDK:', error); return []; } }; - const { data: workshops, isLoading: workshopsLoading, error: workshopsError, refetch: refetchWorkshops } = useQuery({ - queryKey: ['workshops', isClient], - queryFn: fetchWorkshopsFromNDK, + const { data: videos, isLoading: videosLoading, error: videosError, refetch: refetchVideos } = useQuery({ + queryKey: ['videos', isClient], + queryFn: fetchVideosFromNDK, // staleTime: 1000 * 60 * 30, // 30 minutes // refetchInterval: 1000 * 60 * 30, // 30 minutes enabled: isClient, }); - return { workshops, workshopsLoading, workshopsError, refetchWorkshops }; + return { videos, videosLoading, videosError, refetchVideos }; } diff --git a/src/pages/about.js b/src/pages/about.js index f475ff2..e9ee994 100644 --- a/src/pages/about.js +++ b/src/pages/about.js @@ -61,8 +61,8 @@ const AboutPage = () => { description={{draft?.summary}
+{draft?.summary && ( +
{line}
+ ))} +Price: {draft.price}
)} diff --git a/src/pages/index.js b/src/pages/index.js index e2898eb..3cc963c 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,7 +1,7 @@ import Head from 'next/head'; import React from 'react'; import CoursesCarousel from '@/components/content/carousels/CoursesCarousel'; -import WorkshopsCarousel from '@/components/content/carousels/WorkshopsCarousel'; +import VideosCarousel from '@/components/content/carousels/VideosCarousel'; import ResourcesCarousel from '@/components/content/carousels/ResourcesCarousel'; import InteractivePromotionalCarousel from '@/components/content/carousels/InteractivePromotionalCarousel'; @@ -17,7 +17,7 @@ export default function Home() {