@@ -292,4 +292,4 @@ const ResourceForm = ({ draft = null, isPublished = false }) => {
);
}
-export default ResourceForm;
\ No newline at end of file
+export default DocumentForm;
\ No newline at end of file
diff --git a/src/components/forms/course/CourseForm.js b/src/components/forms/course/CourseForm.js
index 866a737..e1f1411 100644
--- a/src/components/forms/course/CourseForm.js
+++ b/src/components/forms/course/CourseForm.js
@@ -9,7 +9,7 @@ import { useRouter } from 'next/router';
import { useToast } from '@/hooks/useToast';
import { parseEvent } from '@/utils/nostr';
import { useDraftsQuery } from '@/hooks/apiQueries/useDraftsQuery';
-import { useResources } from '@/hooks/nostr/useResources';
+import { useDocuments } from '@/hooks/nostr/useDocuments';
import { useVideos } from '@/hooks/nostr/useVideos';
import axios from 'axios';
import LessonSelector from './LessonSelector';
@@ -27,16 +27,17 @@ const CourseForm = ({ draft = null }) => {
const { data: session } = useSession();
const router = useRouter();
const { showToast } = useToast();
- const { resources, resourcesLoading, resourcesError } = useResources();
+ const { documents, documentsLoading, documentsError } = useDocuments();
const { videos, videosLoading, videosError } = useVideos();
const { drafts, draftsLoading, draftsError } = useDraftsQuery();
useEffect(() => {
- if (draft && resources && videos && drafts) {
+ if (draft && documents && videos && drafts) {
const populatedLessons = draft.draftLessons.map((lesson, index) => {
if (lesson?.resource) {
- const matchingResource = resources.find((resource) => resource.d === lesson.resource.d);
- return { ...parseEvent(matchingResource), index };
+ const matchingResource = documents.find((resource) => resource.d === lesson.resource.d);
+ const matchingParsedResource = parseEvent(matchingResource);
+ return { ...matchingParsedResource, index };
} else if (lesson?.draft) {
const matchingDraft = drafts.find((draft) => draft.id === lesson.draft.id);
return { ...matchingDraft, index };
@@ -46,24 +47,15 @@ const CourseForm = ({ draft = null }) => {
setLessons(populatedLessons);
}
- }, [draft, resources, videos, drafts]);
+ }, [draft, documents, videos, drafts]);
useEffect(() => {
- console.log('allContent', allContent);
- }, [allContent]);
-
- useEffect(() => {
- console.log('fasfsa', videos)
- }, [videos])
-
- useEffect(() => {
- if (!resourcesLoading && !videosLoading && !draftsLoading) {
+ if (!documentsLoading && !videosLoading && !draftsLoading) {
let combinedContent = [];
- if (resources) {
- combinedContent = [...combinedContent, ...resources];
+ if (documents) {
+ combinedContent = [...combinedContent, ...documents];
}
if (videos) {
- console.log('workssdfsdfdsf', videos)
combinedContent = [...combinedContent, ...videos];
}
if (drafts) {
@@ -71,7 +63,7 @@ const CourseForm = ({ draft = null }) => {
}
setAllContent(combinedContent);
}
- }, [resources, videos, drafts, resourcesLoading, videosLoading, draftsLoading]);
+ }, [documents, videos, drafts, documentsLoading, videosLoading, draftsLoading]);
const handleSubmit = async (event) => {
event.preventDefault();
@@ -171,7 +163,7 @@ const CourseForm = ({ draft = null }) => {
}
};
- if (resourcesLoading || videosLoading || draftsLoading) {
+ if (documentsLoading || videosLoading || draftsLoading) {
return
;
}
diff --git a/src/components/forms/course/LessonSelector.js b/src/components/forms/course/LessonSelector.js
index be2d19a..1a5969b 100644
--- a/src/components/forms/course/LessonSelector.js
+++ b/src/components/forms/course/LessonSelector.js
@@ -3,14 +3,14 @@ import { Dropdown } from 'primereact/dropdown';
import GenericButton from '@/components/buttons/GenericButton';
import { Dialog } from 'primereact/dialog';
import { Accordion, AccordionTab } from 'primereact/accordion';
-import EmbeddedResourceForm from '@/components/forms/course/embedded/EmbeddedResourceForm';
+import EmbeddedDocumentForm from '@/components/forms/course/embedded/EmbeddedDocumentForm';
import EmbeddedVideoForm from '@/components/forms/course/embedded/EmbeddedVideoForm';
import ContentDropdownItem from '@/components/content/dropdowns/ContentDropdownItem';
import SelectedContentItem from '@/components/content/SelectedContentItem';
import { parseEvent } from '@/utils/nostr';
const LessonSelector = ({ isPaidCourse, lessons, setLessons, allContent, onNewResourceCreate, onNewVideoCreate }) => {
- const [showResourceForm, setShowResourceForm] = useState(false);
+ const [showDocumentForm, setShowDocumentForm] = useState(false);
const [showVideoForm, setShowVideoForm] = useState(false);
const [contentOptions, setContentOptions] = useState([]);
const [openTabs, setOpenTabs] = useState([]);
@@ -47,7 +47,7 @@ const LessonSelector = ({ isPaidCourse, lessons, setLessons, allContent, onNewRe
console.log('filtered content', filteredContent)
- const draftResourceOptions = filteredContent.filter(content => content?.topics.includes('resource') && !content.kind).map(content => ({
+ const draftDocumentOptions = filteredContent.filter(content => content?.topics.includes('document') && !content.kind).map(content => ({
label: content.title,
value: content
}));
@@ -57,7 +57,7 @@ const LessonSelector = ({ isPaidCourse, lessons, setLessons, allContent, onNewRe
value: content
}));
- const resourceOptions = filteredContent.filter(content => content?.topics.includes('resource') && content.kind).map(content => ({
+ const documentOptions = filteredContent.filter(content => content?.topics.includes('document') && content.kind).map(content => ({
label: content.title,
value: content
}));
@@ -69,16 +69,16 @@ const LessonSelector = ({ isPaidCourse, lessons, setLessons, allContent, onNewRe
setContentOptions([
{
- label: 'Draft Resources',
- items: draftResourceOptions
+ label: 'Draft Documents',
+ items: draftDocumentOptions
},
{
label: 'Draft Videos',
items: draftVideoOptions
},
{
- label: 'Published Resources',
- items: resourceOptions
+ label: 'Published Documents',
+ items: documentOptions
},
{
label: 'Published Videos',
@@ -116,16 +116,15 @@ const LessonSelector = ({ isPaidCourse, lessons, setLessons, allContent, onNewRe
setLessons([...lessons, { index: lessons.length }]);
};
- const handleNewResourceSave = async (newResource) => {
- const createdResource = await onNewResourceCreate(newResource);
- if (createdResource) {
- handleContentSelect(createdResource, lessons.length);
- setShowResourceForm(false);
+ const handleNewDocumentSave = async (newDocument) => {
+ const createdDocument = await onNewDocumentCreate(newDocument);
+ if (createdDocument) {
+ handleContentSelect(createdDocument, lessons.length);
+ setShowDocumentForm(false);
}
};
const handleNewVideoSave = async (newVideo) => {
- console.log('newVideo', newVideo);
const createdVideo = await onNewVideoCreate(newVideo);
if (createdVideo) {
handleContentSelect(createdVideo, lessons.length);
@@ -167,7 +166,7 @@ const LessonSelector = ({ isPaidCourse, lessons, setLessons, allContent, onNewRe
{lesson.id ? null : (
<>
- {e.preventDefault(); setShowResourceForm(true)}} className="mr-2" />
+ {e.preventDefault(); setShowDocumentForm(true)}} className="mr-2" />
{e.preventDefault(); setShowVideoForm(true)}} className="mr-2" />
>
)}
@@ -187,11 +186,11 @@ const LessonSelector = ({ isPaidCourse, lessons, setLessons, allContent, onNewRe
label="Add New Lesson"
onClick={addNewLesson}
className="mt-4"
- type="button" // Explicitly set type to "button"
+ type="button"
/>
-
-
Paid Resource
+
Paid Document
setIsPaidResource(e.value)} />
{isPaidResource && (
@@ -223,4 +223,4 @@ const EmbeddedResourceForm = ({ draft = null, isPublished = false, onSave, isPai
);
}
-export default EmbeddedResourceForm;
\ No newline at end of file
+export default EmbeddedDocumentForm;
\ No newline at end of file
diff --git a/src/components/profile/UserContent.js b/src/components/profile/UserContent.js
index 477233b..1c5118d 100644
--- a/src/components/profile/UserContent.js
+++ b/src/components/profile/UserContent.js
@@ -3,7 +3,7 @@ import { useRouter } from "next/router";
import GenericButton from "@/components/buttons/GenericButton";
import MenuTab from "@/components/menutab/MenuTab";
import { useCourses } from "@/hooks/nostr/useCourses";
-import { useResources } from "@/hooks/nostr/useResources";
+import { useDocuments } from "@/hooks/nostr/useDocuments";
import { useVideos } from "@/hooks/nostr/useVideos";
import { useDraftsQuery } from "@/hooks/apiQueries/useDraftsQuery";
import { useCourseDraftsQuery } from "@/hooks/apiQueries/useCourseDraftsQuery";
@@ -31,7 +31,7 @@ const UserContent = () => {
const { showToast } = useToast();
const {ndk, addSigner} = useNDKContext();
const { courses, coursesLoading, coursesError } = useCourses();
- const { resources, resourcesLoading, resourcesError } = useResources();
+ const { documents, documentsLoading, documentsError } = useDocuments();
const { videos, videosLoading, videosError } = useVideos();
const { courseDrafts, courseDraftsLoading, courseDraftsError } = useCourseDraftsQuery();
const { drafts, draftsLoading, draftsError } = useDraftsQuery();
@@ -51,7 +51,7 @@ const UserContent = () => {
{ label: "Published", icon: "pi pi-verified" },
{ label: "Drafts", icon: "pi pi-file-edit" },
{ label: "Draft Courses", icon: "pi pi-book" },
- { label: "Resources", icon: "pi pi-file" },
+ { label: "Documents", icon: "pi pi-file" },
{ label: "Videos", icon: "pi pi-video" },
{ label: "Courses", icon: "pi pi-desktop" },
];
@@ -98,8 +98,8 @@ const UserContent = () => {
case 2:
return courseDrafts || [];
case 3:
- return resources?.map(parseEvent) || [];
- case 3:
+ return documents?.map(parseEvent) || [];
+ case 4:
return videos?.map(parseEvent) || [];
case 4:
return courses?.map(parseEvent) || [];
@@ -110,10 +110,10 @@ const UserContent = () => {
setContent(getContentByIndex(activeIndex));
}
- }, [activeIndex, isClient, drafts, resources, videos, courses, publishedContent, courseDrafts])
+ }, [activeIndex, isClient, drafts, documents, videos, courses, publishedContent, courseDrafts])
- const isLoading = coursesLoading || resourcesLoading || videosLoading || draftsLoading || contentIdsLoading || courseDraftsLoading;
- const isError = coursesError || resourcesError || videosError || draftsError || contentIdsError || courseDraftsError;
+ const isLoading = coursesLoading || documentsLoading || videosLoading || draftsLoading || contentIdsLoading || courseDraftsLoading;
+ const isError = coursesError || documentsError || videosError || draftsError || contentIdsError || courseDraftsError;
return (
diff --git a/src/components/sidebar/Sidebar.js b/src/components/sidebar/Sidebar.js
index b48eac0..5c23025 100644
--- a/src/components/sidebar/Sidebar.js
+++ b/src/components/sidebar/Sidebar.js
@@ -40,38 +40,42 @@ const Sidebar = ({ course = false }) => {
if (router.isReady) {
const { slug } = router.query;
- if (slug && course) {
- const { data } = nip19.decode(slug)
+ try {
+ if (slug && course) {
+ const { data } = nip19.decode(slug)
- if (!data) {
- showToast('error', 'Error', 'Course not found');
- return;
- }
-
- const id = data?.identifier;
- const fetchCourse = async (id) => {
- try {
- await ndk.connect();
-
- const filter = {
- ids: [id]
- }
-
- const event = await ndk.fetchEvent(filter);
-
- if (event) {
- // all a tags are lessons
- const lessons = event.tags.filter(tag => tag[0] === 'a');
- const uniqueLessons = [...new Set(lessons.map(lesson => lesson[1]))];
- setLessons(uniqueLessons);
- }
- } catch (error) {
- console.error('Error fetching event:', error);
+ if (!data) {
+ showToast('error', 'Error', 'Course not found');
+ return;
+ }
+
+ const id = data?.identifier;
+ const fetchCourse = async (id) => {
+ try {
+ await ndk.connect();
+
+ const filter = {
+ ids: [id]
+ }
+
+ const event = await ndk.fetchEvent(filter);
+
+ if (event) {
+ // all a tags are lessons
+ const lessons = event.tags.filter(tag => tag[0] === 'a');
+ const uniqueLessons = [...new Set(lessons.map(lesson => lesson[1]))];
+ setLessons(uniqueLessons);
+ }
+ } catch (error) {
+ console.error('Error fetching event:', error);
+ }
+ };
+ if (ndk && id) {
+ fetchCourse(id);
}
- };
- if (ndk && id) {
- fetchCourse(id);
}
+ } catch (err) {
+ console.error(err);
}
}
}, [router.isReady, router.query, ndk, course]);
@@ -136,8 +140,8 @@ const Sidebar = ({ course = false }) => {
router.push('/content?tag=videos')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=videos') ? 'bg-gray-700' : ''}`}>
Videos
-
router.push('/content?tag=resources')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=resources') ? 'bg-gray-700' : ''}`}>
-
Resources
+
router.push('/content?tag=documents')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=documents') ? 'bg-gray-700' : ''}`}>
+
Documents
diff --git a/src/hooks/nostr/useResources.js b/src/hooks/nostr/useDocuments.js
similarity index 57%
rename from src/hooks/nostr/useResources.js
rename to src/hooks/nostr/useDocuments.js
index a4ee7db..b0f7df8 100644
--- a/src/hooks/nostr/useResources.js
+++ b/src/hooks/nostr/useDocuments.js
@@ -4,12 +4,12 @@ import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
-export function useResources() {
+export function useDocuments() {
const [isClient, setIsClient] = useState(false);
- const [resources, setResources] = useState();
+ const [documents, setDocuments] = useState();
// Add new state variables for loading and error
- const [resourcesLoading, setResourcesLoading] = useState(false);
- const [resourcesError, setResourcesError] = useState(null);
+ const [documentsLoading, setDocumentsLoading] = useState(false);
+ const [documentsError, setDocumentsError] = useState(null);
const { contentIds } = useContentIdsQuery()
const {ndk, addSigner} = useNDKContext();
@@ -19,18 +19,18 @@ export function useResources() {
}, []);
const hasRequiredProperties = (event, contentIds) => {
- const hasResource = event.tags.some(([tag, value]) => tag === "t" && value === "resource");
+ const hasDocument = event.tags.some(([tag, value]) => tag === "t" && value === "document");
const hasId = event.tags.some(([tag, value]) => tag === "d" && contentIds.includes(value));
- return hasResource && hasId;
+ return hasDocument && hasId;
};
- const fetchResourcesFromNDK = async () => {
- setResourcesLoading(true);
- setResourcesError(null);
+ const fetchDocumentsFromNDK = async () => {
+ setDocumentsLoading(true);
+ setDocumentsError(null);
try {
if (!contentIds || contentIds.length === 0) {
console.log('No content IDs found');
- setResourcesLoading(false);
+ setDocumentsLoading(false);
return []; // Return early if no content IDs are found
}
@@ -41,29 +41,29 @@ export function useResources() {
if (events && events.size > 0) {
const eventsArray = Array.from(events);
- const resources = eventsArray.filter(event => hasRequiredProperties(event, contentIds));
- setResourcesLoading(false);
- return resources;
+ const documents = eventsArray.filter(event => hasRequiredProperties(event, contentIds));
+ setDocumentsLoading(false);
+ return documents;
}
- setResourcesLoading(false);
+ setDocumentsLoading(false);
return [];
} catch (error) {
- console.error('Error fetching resources from NDK:', error);
- setResourcesError(error);
- setResourcesLoading(false);
+ console.error('Error fetching documents from NDK:', error);
+ setDocumentsError(error);
+ setDocumentsLoading(false);
return [];
}
};
useEffect(() => {
if (isClient && contentIds) {
- fetchResourcesFromNDK().then(fetchedResources => {
- if (fetchedResources && fetchedResources.length > 0) {
- setResources(fetchedResources);
+ fetchDocumentsFromNDK().then(fetchedDocuments => {
+ if (fetchedDocuments && fetchedDocuments.length > 0) {
+ setDocuments(fetchedDocuments);
}
});
}
}, [isClient, contentIds]);
- return { resources, resourcesLoading, resourcesError };
+ return { documents, documentsLoading, documentsError };
}
\ No newline at end of file
diff --git a/src/hooks/nostrQueries/content/useResourcesQuery.js b/src/hooks/nostrQueries/content/useDocumentsQuery.js
similarity index 68%
rename from src/hooks/nostrQueries/content/useResourcesQuery.js
rename to src/hooks/nostrQueries/content/useDocumentsQuery.js
index 6229ed6..3f9d8c1 100644
--- a/src/hooks/nostrQueries/content/useResourcesQuery.js
+++ b/src/hooks/nostrQueries/content/useDocumentsQuery.js
@@ -5,7 +5,7 @@ import axios from 'axios';
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
-export function useResourcesQuery() {
+export function useDocumentsQuery() {
const [isClient, setIsClient] = useState(false);
const {ndk, addSigner} = useNDKContext();
@@ -14,12 +14,12 @@ export function useResourcesQuery() {
}, []);
const hasRequiredProperties = (event, contentIds) => {
- const hasResource = event.tags.some(([tag, value]) => tag === "t" && value === "resource");
+ const hasDocument = event.tags.some(([tag, value]) => tag === "t" && value === "document");
const hasId = event.tags.some(([tag, value]) => tag === "d" && contentIds.includes(value));
- return hasResource && hasId;
+ return hasDocument && hasId;
};
- const fetchResourcesFromNDK = async () => {
+ const fetchDocumentsFromNDK = async () => {
try {
const response = await axios.get(`/api/content/all`);
const contentIds = response.data;
@@ -36,23 +36,23 @@ export function useResourcesQuery() {
if (events && events.size > 0) {
const eventsArray = Array.from(events);
- const resources = eventsArray.filter(event => hasRequiredProperties(event, contentIds));
- return resources;
+ const documents = eventsArray.filter(event => hasRequiredProperties(event, contentIds));
+ return documents;
}
return [];
} catch (error) {
- console.error('Error fetching resources from NDK:', error);
+ console.error('Error fetching documents from NDK:', error);
return [];
}
};
- const { data: resources, isLoading: resourcesLoading, error: resourcesError, refetch: refetchResources } = useQuery({
- queryKey: ['resources', isClient],
- queryFn: fetchResourcesFromNDK,
+ const { data: documents, isLoading: documentsLoading, error: documentsError, refetch: refetchDocuments } = useQuery({
+ queryKey: ['documents', isClient],
+ queryFn: fetchDocumentsFromNDK,
// staleTime: 1000 * 60 * 30, // 30 minutes
// refetchInterval: 1000 * 60 * 30, // 30 minutes
enabled: isClient,
});
- return { resources, resourcesLoading, resourcesError, refetchResources };
+ return { documents, documentsLoading, documentsError, refetchDocuments };
}
diff --git a/src/pages/_app.js b/src/pages/_app.js
index f645c5b..afa9293 100644
--- a/src/pages/_app.js
+++ b/src/pages/_app.js
@@ -29,7 +29,7 @@ export default function MyApp({
const router = useRouter();
useEffect(() => {
- setIsCourseView(router.pathname.includes('course'));
+ setIsCourseView(router.pathname.includes('course') && !router.pathname.includes('draft'));
}, [router.pathname]);
// const [sidebarExpanded, setSidebarExpanded] = useState(true);
diff --git a/src/pages/about.js b/src/pages/about.js
index e9ee994..91f554e 100644
--- a/src/pages/about.js
+++ b/src/pages/about.js
@@ -60,9 +60,9 @@ const AboutPage = () => {
title="Content Types"
description={
- - Resources: Markdown documents posted as NIP-23 long-form events on Nostr.
+ - Documents: Markdown documents posted as NIP-23 long-form events on Nostr.
- Videos: Enhanced markdown files with rich media support, including embedded videos, also saved as NIP-23 events.
- - Courses: Nostr lists that combine multiple resources and videos into a structured learning path.
+ - Courses: Nostr lists that combine multiple documents and videos into a structured learning path.
}
/>
diff --git a/src/pages/content/index.js b/src/pages/content/index.js
index aade97a..41eb4b2 100644
--- a/src/pages/content/index.js
+++ b/src/pages/content/index.js
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react';
import GenericCarousel from '@/components/content/carousels/GenericCarousel';
import { parseEvent, parseCourseEvent } from '@/utils/nostr';
-import { useResources } from '@/hooks/nostr/useResources';
+import { useDocuments } from '@/hooks/nostr/useDocuments';
import { useVideos } from '@/hooks/nostr/useVideos';
import { useCourses } from '@/hooks/nostr/useCourses';
import { TabMenu } from 'primereact/tabmenu';
@@ -17,7 +17,7 @@ const MenuTab = ({ items, selectedTopic, onTabChange }) => {
const menuItems = allItems.map((item, index) => {
let icon = 'pi pi-tag';
if (item === 'All') icon = 'pi pi-eye';
- else if (item === 'Resources') icon = 'pi pi-file';
+ else if (item === 'Documents') icon = 'pi pi-file';
else if (item === 'Videos') icon = 'pi pi-video';
else if (item === 'Courses') icon = 'pi pi-desktop';
@@ -67,11 +67,11 @@ const MenuTab = ({ items, selectedTopic, onTabChange }) => {
const ContentPage = () => {
const router = useRouter();
- const { resources, resourcesLoading } = useResources();
+ const { documents, documentsLoading } = useDocuments();
const { videos, videosLoading } = useVideos();
const { courses, coursesLoading } = useCourses();
- const [processedResources, setProcessedResources] = useState([]);
+ const [processedDocuments, setProcessedDocuments] = useState([]);
const [processedVideos, setProcessedVideos] = useState([]);
const [processedCourses, setProcessedCourses] = useState([]);
const [allContent, setAllContent] = useState([]);
@@ -92,11 +92,11 @@ const ContentPage = () => {
}, [router.query.tag]);
useEffect(() => {
- if (resources && !resourcesLoading) {
- const processedResources = resources.map(resource => ({...parseEvent(resource), type: 'resource'}));
- setProcessedResources(processedResources);
+ if (documents && !documentsLoading) {
+ const processedDocuments = documents.map(document => ({...parseEvent(document), type: 'document'}));
+ setProcessedDocuments(processedDocuments);
}
- }, [resources, resourcesLoading]);
+ }, [documents, documentsLoading]);
useEffect(() => {
if (videos && !videosLoading) {
@@ -113,11 +113,11 @@ const ContentPage = () => {
}, [courses, coursesLoading]);
useEffect(() => {
- const allContent = [...processedResources, ...processedVideos, ...processedCourses];
+ const allContent = [...processedDocuments, ...processedVideos, ...processedCourses];
setAllContent(allContent);
const uniqueTopics = new Set(allContent.map(item => item.topics).flat());
- const priorityItems = ['All', 'Courses', 'Videos', 'Resources'];
+ const priorityItems = ['All', 'Courses', 'Videos', 'Documents'];
const otherTopics = Array.from(uniqueTopics).filter(topic => !priorityItems.includes(topic));
const combinedTopics = [...priorityItems.slice(1), ...otherTopics];
setAllTopics(combinedTopics);
@@ -125,13 +125,13 @@ const ContentPage = () => {
if (selectedTopic) {
filterContent(selectedTopic, allContent);
}
- }, [processedResources, processedVideos, processedCourses]);
+ }, [processedDocuments, processedVideos, processedCourses]);
const filterContent = (topic, content) => {
let filtered = content;
if (topic !== 'All') {
const topicLower = topic.toLowerCase();
- if (['courses', 'videos', 'resources'].includes(topicLower)) {
+ if (['courses', 'videos', 'documents'].includes(topicLower)) {
filtered = content.filter(item => item.type === topicLower.slice(0, -1));
} else {
filtered = content.filter(item => item.topics && item.topics.includes(topic.toLowerCase()));
@@ -166,7 +166,7 @@ const ContentPage = () => {
All Content
!['Courses', 'Videos', 'Resources'].includes(topic))]}
+ items={['Courses', 'Videos', 'Documents', ...allTopics.filter(topic => !['Courses', 'Videos', 'Documents'].includes(topic))]}
selectedTopic={selectedTopic}
onTabChange={handleTopicChange}
className="max-w-[90%] mx-auto"
diff --git a/src/pages/course/[slug]/draft/index.js b/src/pages/course/[slug]/draft/index.js
index 5ea358b..00eede9 100644
--- a/src/pages/course/[slug]/draft/index.js
+++ b/src/pages/course/[slug]/draft/index.js
@@ -44,7 +44,6 @@ const DraftCourse = () => {
axios.get(`/api/courses/drafts/${slug}`)
.then(res => {
setCourse(res.data);
- console.log('coursesssss:', res.data);
setLessons(res.data.draftLessons);
})
.catch(err => {
diff --git a/src/pages/course/[slug]/index.js b/src/pages/course/[slug]/index.js
index 366137e..111ffa0 100644
--- a/src/pages/course/[slug]/index.js
+++ b/src/pages/course/[slug]/index.js
@@ -53,16 +53,19 @@ const useCourseData = (ndk, fetchAuthor, router) => {
return { course, lessonIds };
};
-const useLessons = (ndk, fetchAuthor, lessonIds) => {
+const useLessons = (ndk, fetchAuthor, lessonIds, pubkey) => {
const [lessons, setLessons] = useState([]);
const [uniqueLessons, setUniqueLessons] = useState([]);
+ console.log('lessonIds', lessonIds);
+
useEffect(() => {
if (lessonIds.length > 0) {
const fetchLesson = async (lessonId) => {
+ console.log('lessonId', lessonId);
try {
await ndk.connect();
- const filter = { "#d": [lessonId] };
+ const filter = { "#d": [lessonId], kinds:[30023, 30402], authors: [pubkey] };
const event = await ndk.fetchEvent(filter);
if (event) {
const author = await fetchAuthor(event.pubkey);
@@ -83,6 +86,10 @@ const useLessons = (ndk, fetchAuthor, lessonIds) => {
setUniqueLessons(newUniqueLessons);
}, [lessons]);
+ useEffect(() => {
+ console.log('uniqueLessons', uniqueLessons);
+ }, [uniqueLessons]);
+
return { lessons, uniqueLessons, setLessons };
};
@@ -139,7 +146,7 @@ const Course = () => {
}, [ndk]);
const { course, lessonIds } = useCourseData(ndk, fetchAuthor, router);
- const { lessons, uniqueLessons, setLessons } = useLessons(ndk, fetchAuthor, lessonIds);
+ const { lessons, uniqueLessons, setLessons } = useLessons(ndk, fetchAuthor, lessonIds, course?.pubkey);
const { decryptionPerformed, loading } = useDecryption(session, paidCourse, course, lessons, setLessons);
useEffect(() => {
diff --git a/src/pages/create.js b/src/pages/create.js
index 654abab..62cc553 100644
--- a/src/pages/create.js
+++ b/src/pages/create.js
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import MenuTab from "@/components/menutab/MenuTab";
-import ResourceForm from "@/components/forms/ResourceForm";
+import DocumentForm from "@/components/forms/DocumentForm";
import VideoForm from "@/components/forms/VideoForm";
import CourseForm from "@/components/forms/course/CourseForm";
import { useIsAdmin } from "@/hooks/useIsAdmin";
@@ -12,7 +12,7 @@ const Create = () => {
const { isAdmin, isLoading } = useIsAdmin();
const router = useRouter();
const homeItems = [
- { label: 'Resource', icon: 'pi pi-book' },
+ { label: 'Document', icon: 'pi pi-file' },
{ label: 'Video', icon: 'pi pi-video' },
{ label: 'Course', icon: 'pi pi-desktop' }
];
@@ -32,8 +32,8 @@ const Create = () => {
return ;
case 'Video':
return ;
- case 'Resource':
- return ;
+ case 'Document':
+ return ;
default:
return null; // or a default component
}
diff --git a/src/pages/details/[slug]/edit.js b/src/pages/details/[slug]/edit.js
index 6e3d7cc..aa3158c 100644
--- a/src/pages/details/[slug]/edit.js
+++ b/src/pages/details/[slug]/edit.js
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from "react";
import { useRouter } from "next/router";
import { parseEvent } from "@/utils/nostr";
-import ResourceForm from "@/components/forms/ResourceForm";
+import DocumentForm from "@/components/forms/DocumentForm";
import VideoForm from "@/components/forms/VideoForm";
import CourseForm from "@/components/forms/course/CourseForm";
import { useNDKContext } from "@/context/NDKContext";
@@ -41,7 +41,7 @@ export default function Edit() {
Edit Published Event
{event?.topics.includes('course') && }
{!event?.topics.includes('video') && }
- {event?.topics.includes('resource') && }
+ {event?.topics.includes('document') && }
);
}
diff --git a/src/pages/draft/[slug]/edit.js b/src/pages/draft/[slug]/edit.js
index d5130f5..8e7e06a 100644
--- a/src/pages/draft/[slug]/edit.js
+++ b/src/pages/draft/[slug]/edit.js
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from "react";
import { useRouter } from "next/router";
import axios from "axios";
-import ResourceForm from "@/components/forms/ResourceForm";
+import DocumentForm from "@/components/forms/DocumentForm";
import VideoForm from "@/components/forms/VideoForm";
import CourseForm from "@/components/forms/course/CourseForm";
import { useIsAdmin } from "@/hooks/useIsAdmin";
@@ -38,7 +38,7 @@ const Edit = () => {
Edit Draft
{draft?.type === 'course' &&
}
{draft?.type === 'video' &&
}
- {draft?.type === 'resource' &&
}
+ {draft?.type === 'document' &&
}
);
};
diff --git a/src/pages/draft/[slug]/index.js b/src/pages/draft/[slug]/index.js
index 6563713..14ab0a9 100644
--- a/src/pages/draft/[slug]/index.js
+++ b/src/pages/draft/[slug]/index.js
@@ -32,6 +32,7 @@ export default function Draft() {
const { returnImageProxy } = useImageProxy();
const { data: session, status } = useSession();
const [user, setUser] = useState(null);
+ const [nAddress, setNAddress] = useState(null);
const [videoId, setVideoId] = useState(null);
const { width, height } = useResponsiveImageDimensions();
const router = useRouter();
@@ -187,7 +188,7 @@ export default function Draft() {
console.log('NewDTag:', NewDTag);
switch (draft?.type) {
- case 'resource':
+ case 'document':
if (draft?.price) {
// encrypt the content with NEXT_PUBLIC_APP_PRIV_KEY to NEXT_PUBLIC_APP_PUBLIC_KEY
encryptedContent = await nip04.encrypt(process.env.NEXT_PUBLIC_APP_PRIV_KEY, process.env.NEXT_PUBLIC_APP_PUBLIC_KEY, draft.content);
@@ -208,7 +209,7 @@ export default function Draft() {
...(draft?.additionalLinks ? draft.additionalLinks.map(link => ['r', link]) : []),
];
- type = 'resource';
+ type = 'document';
break;
case 'video':
if (draft?.price) {
@@ -315,7 +316,7 @@ export default function Draft() {
{draft && (
-
router.push(`/details/${draft.id}`)} className="flex flex-col items-center mx-auto cursor-pointer rounded-md shadow-lg">
+
router.push(`/details/${nAddress}`)} className="flex flex-col items-center mx-auto cursor-pointer rounded-md shadow-lg">
-
+
>
);
diff --git a/src/utils/nostr.js b/src/utils/nostr.js
index 2108cf5..dca479b 100644
--- a/src/utils/nostr.js
+++ b/src/utils/nostr.js
@@ -63,7 +63,7 @@ export const parseEvent = (event) => {
image: '',
published_at: '',
topics: [], // Added to hold all topics
- type: 'resource', // Default type
+ type: 'document', // Default type
};
// Iterate over the tags array to extract data