mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Improvements with course flow, just need to work on unpublished
This commit is contained in:
parent
06209b6371
commit
d794c20678
@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Carousel } from 'primereact/carousel';
|
import { Carousel } from 'primereact/carousel';
|
||||||
import { parseEvent } from '@/utils/nostr';
|
import { parseCourseEvent } from '@/utils/nostr';
|
||||||
import { useNostr } from '@/hooks/useNostr';
|
import { useNostr } from '@/hooks/useNostr';
|
||||||
import CourseTemplate from '@/components/content/carousels/templates/CourseTemplate';
|
import CourseTemplate from '@/components/content/carousels/templates/CourseTemplate';
|
||||||
import TemplateSkeleton from '@/components/content/carousels/skeletons/TemplateSkeleton';
|
import TemplateSkeleton from '@/components/content/carousels/skeletons/TemplateSkeleton';
|
||||||
@ -34,7 +34,7 @@ export default function CoursesCarousel() {
|
|||||||
console.log('fetchedCourses:', fetchedCourses);
|
console.log('fetchedCourses:', fetchedCourses);
|
||||||
if (fetchedCourses && fetchedCourses.length > 0) {
|
if (fetchedCourses && fetchedCourses.length > 0) {
|
||||||
// First process the courses to be ready for display
|
// First process the courses to be ready for display
|
||||||
const processedCourses = fetchedCourses.map(course => parseEvent(course));
|
const processedCourses = fetchedCourses.map(course => parseCourseEvent(course));
|
||||||
console.log('processedCourses:', processedCourses);
|
console.log('processedCourses:', processedCourses);
|
||||||
|
|
||||||
// Fetch zaps for all processed courses at once
|
// Fetch zaps for all processed courses at once
|
||||||
|
@ -27,7 +27,6 @@ const CourseTemplate = (course) => {
|
|||||||
setZapAmount(total);
|
setZapAmount(total);
|
||||||
}, [course]);
|
}, [course]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex flex-col items-center mx-auto px-4 mt-8 rounded-md"
|
className="flex flex-col items-center mx-auto px-4 mt-8 rounded-md"
|
||||||
@ -48,12 +47,17 @@ const CourseTemplate = (course) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col justify-start w-full mt-4">
|
<div className="flex flex-col justify-start w-full mt-4">
|
||||||
<h4 className="mb-1 font-bold text-lg font-blinker line-clamp-2">
|
<h4 className="mb-1 font-bold text-lg font-blinker line-clamp-2">
|
||||||
{course.title}
|
{course.name || course.title}
|
||||||
</h4>
|
</h4>
|
||||||
<p className="text-sm text-gray-500 line-clamp-2">{course.summary}</p>
|
<p className="text-sm text-gray-500 line-clamp-2">{course.description || course.summary}</p>
|
||||||
<div className="flex flex-row justify-between items-center mt-2">
|
<div className="flex flex-row justify-between items-center mt-2">
|
||||||
<p className="text-xs text-gray-400">
|
<p className="text-xs text-gray-400">
|
||||||
{formatTimestampToHowLongAgo(course.published_at)}
|
{course?.published_at && course.published_at !== "" ? (
|
||||||
|
formatTimestampToHowLongAgo(course.published_at)
|
||||||
|
) : (
|
||||||
|
formatTimestampToHowLongAgo(course.created_at)
|
||||||
|
)
|
||||||
|
}
|
||||||
</p>
|
</p>
|
||||||
<ZapDisplay zapAmount={zapAmount} event={course} />
|
<ZapDisplay zapAmount={zapAmount} event={course} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,11 +111,15 @@ const CourseForm = () => {
|
|||||||
}),
|
}),
|
||||||
axios.delete(`/api/drafts/${lesson.id}`)
|
axios.delete(`/api/drafts/${lesson.id}`)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processedLessons.push({ id: lesson?.d });
|
processedLessons.push({ id: lesson?.d || lesson.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to set aside a final processed lessons that included lesson.kind, lesson.pubkey, lesson.d
|
||||||
|
|
||||||
// Step 2: Create and publish course
|
// Step 2: Create and publish course
|
||||||
const courseEvent = createCourseEvent(newCourseId, title, summary, coverImage, selectedLessons);
|
const courseEvent = createCourseEvent(newCourseId, title, summary, coverImage, selectedLessons);
|
||||||
const signedCourseEvent = await window.nostr.signEvent(courseEvent);
|
const signedCourseEvent = await window.nostr.signEvent(courseEvent);
|
||||||
|
@ -92,8 +92,10 @@ export const parseCourseEvent = (event) => {
|
|||||||
description: '',
|
description: '',
|
||||||
image: '',
|
image: '',
|
||||||
published_at: '',
|
published_at: '',
|
||||||
|
created_at: event.created_at,
|
||||||
topics: [],
|
topics: [],
|
||||||
d: '',
|
d: '',
|
||||||
|
tags: event.tags
|
||||||
};
|
};
|
||||||
|
|
||||||
// Iterate over the tags array to extract data
|
// Iterate over the tags array to extract data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user