{title}
+ {isLesson &&
}
{topics && topics.length > 0 && (
topics.map((topic, index) => (
@@ -165,11 +179,12 @@ const VideoDetails = ({ processedEvent, topics, title, summary, image, price, au
router.push(`/details/${nAddress}/edit`)} label="Edit" severity='warning' outlined />
- window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={ isMobileView ? null : "View Nostr Event" } tooltipOptions={{ position: 'right' }} />
+ window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={isMobileView ? null : "View Nostr Event"} tooltipOptions={{ position: 'right' }} />
) : (
- window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={ isMobileView ? null : "View Nostr Event" } tooltipOptions={{ position: paidResource ? 'left' : 'right' }} />
+ {course && window.open(`/course/${course}`, '_blank')} label="Open Course" tooltip="This is a lesson in a course" tooltipOptions={{ position: 'top' }} />}
+ window.open(`https://nostr.band/${nAddress}`, '_blank')} tooltip={isMobileView ? null : "View Nostr Event"} tooltipOptions={{ position: paidResource ? 'left' : 'right' }} />
)}
diff --git a/src/hooks/tracking/useTrackDocumentLesson.js b/src/hooks/tracking/useTrackDocumentLesson.js
index 51d0cd4..c61a712 100644
--- a/src/hooks/tracking/useTrackDocumentLesson.js
+++ b/src/hooks/tracking/useTrackDocumentLesson.js
@@ -14,7 +14,6 @@ const useTrackDocumentLesson = ({ lessonId, courseId, readTime, paidCourse, decr
useEffect(() => {
if (session?.user?.role?.admin) {
setIsAdmin(true);
- setIsCompleted(true); // Automatically mark as completed for admins
}
}, [session]);
diff --git a/src/hooks/tracking/useTrackVideoLesson.js b/src/hooks/tracking/useTrackVideoLesson.js
index 2de2742..1fd0183 100644
--- a/src/hooks/tracking/useTrackVideoLesson.js
+++ b/src/hooks/tracking/useTrackVideoLesson.js
@@ -14,7 +14,6 @@ const useTrackVideoLesson = ({lessonId, videoDuration, courseId, videoPlayed, pa
useEffect(() => {
if (session?.user?.role?.admin) {
setIsAdmin(true);
- setIsCompleted(true); // Automatically mark as completed for admins
}
}, [session]);
diff --git a/src/pages/content/index.js b/src/pages/content/index.js
index 4043098..fedd338 100644
--- a/src/pages/content/index.js
+++ b/src/pages/content/index.js
@@ -12,7 +12,8 @@ import { useRouter } from 'next/router';
const MenuTab = ({ items, selectedTopic, onTabChange }) => {
const router = useRouter();
- const allItems = ['All', ...items];
+ // spread the items except for 'document' 'video' and 'course'
+ const allItems = ['All', ...items.filter(item => item !== 'document' && item !== 'video' && item !== 'course')];
const menuItems = allItems.map((item, index) => {
let icon = 'pi pi-tag';
diff --git a/src/pages/details/[slug]/index.js b/src/pages/details/[slug]/index.js
index 3f0b25e..f1aa518 100644
--- a/src/pages/details/[slug]/index.js
+++ b/src/pages/details/[slug]/index.js
@@ -9,6 +9,7 @@ import { useDecryptContent } from "@/hooks/encryption/useDecryptContent";
import { useToast } from "@/hooks/useToast";
import { useRouter } from "next/router";
import { ProgressSpinner } from 'primereact/progressspinner';
+import axios from 'axios';
import ZapThreadsWrapper from '@/components/ZapThreadsWrapper';
import { appConfig } from "@/config/appConfig";
@@ -19,12 +20,25 @@ const Details = () => {
const [decryptedContent, setDecryptedContent] = useState(null);
const [authorView, setAuthorView] = useState(false);
const [loading, setLoading] = useState(true);
+ const [lessons, setLessons] = useState([]);
const { data: session } = useSession();
const { ndk } = useNDKContext();
const { decryptContent } = useDecryptContent();
const router = useRouter();
const { showToast } = useToast();
+ useEffect(() => {
+ axios.get('/api/lessons').then(res => {
+ if (res.data) {
+ res.data.forEach(lesson => {
+ setLessons(prev => [...prev, lesson?.resourceId]);
+ });
+ }
+ }).catch(err => {
+ console.log('err', err);
+ });
+ }, []);
+
const fetchAuthor = useCallback(async (pubkey) => {
if (!pubkey) return;
const author = await ndk.getUser({ pubkey });
@@ -140,6 +154,7 @@ const Details = () => {
price={event.price}
author={author}
paidResource={!!event.price}
+ isLesson={lessons.includes(event.d)}
nAddress={nAddress}
decryptedContent={decryptedContent}
handlePaymentSuccess={handlePaymentSuccess}