mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-04-19 19:01:19 +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 { Carousel } from 'primereact/carousel';
|
||||
import { parseEvent } from '@/utils/nostr';
|
||||
import { parseCourseEvent } from '@/utils/nostr';
|
||||
import { useNostr } from '@/hooks/useNostr';
|
||||
import CourseTemplate from '@/components/content/carousels/templates/CourseTemplate';
|
||||
import TemplateSkeleton from '@/components/content/carousels/skeletons/TemplateSkeleton';
|
||||
@ -34,7 +34,7 @@ export default function CoursesCarousel() {
|
||||
console.log('fetchedCourses:', fetchedCourses);
|
||||
if (fetchedCourses && fetchedCourses.length > 0) {
|
||||
// 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);
|
||||
|
||||
// Fetch zaps for all processed courses at once
|
||||
|
@ -14,7 +14,7 @@ const CourseTemplate = (course) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!course || !course.zaps) return;
|
||||
|
||||
|
||||
let total = 0;
|
||||
course.zaps.forEach((zap) => {
|
||||
const bolt11Tag = zap.tags.find(tag => tag[0] === "bolt11");
|
||||
@ -27,7 +27,6 @@ const CourseTemplate = (course) => {
|
||||
setZapAmount(total);
|
||||
}, [course]);
|
||||
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex flex-col items-center mx-auto px-4 mt-8 rounded-md"
|
||||
@ -48,12 +47,17 @@ const CourseTemplate = (course) => {
|
||||
</div>
|
||||
<div className="flex flex-col justify-start w-full mt-4">
|
||||
<h4 className="mb-1 font-bold text-lg font-blinker line-clamp-2">
|
||||
{course.title}
|
||||
{course.name || course.title}
|
||||
</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">
|
||||
<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>
|
||||
<ZapDisplay zapAmount={zapAmount} event={course} />
|
||||
</div>
|
||||
|
@ -111,11 +111,15 @@ const CourseForm = () => {
|
||||
}),
|
||||
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
|
||||
const courseEvent = createCourseEvent(newCourseId, title, summary, coverImage, selectedLessons);
|
||||
const signedCourseEvent = await window.nostr.signEvent(courseEvent);
|
||||
|
@ -92,8 +92,10 @@ export const parseCourseEvent = (event) => {
|
||||
description: '',
|
||||
image: '',
|
||||
published_at: '',
|
||||
created_at: event.created_at,
|
||||
topics: [],
|
||||
d: '',
|
||||
tags: event.tags
|
||||
};
|
||||
|
||||
// Iterate over the tags array to extract data
|
||||
|
Loading…
x
Reference in New Issue
Block a user