mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-04-19 19:01:19 +00:00
Improvements to course details
This commit is contained in:
parent
b8b10907bb
commit
4232c1963b
@ -21,16 +21,8 @@ const MDDisplay = dynamic(
|
||||
}
|
||||
);
|
||||
|
||||
const BitcoinConnectPayButton = dynamic(
|
||||
() => import('@getalby/bitcoin-connect-react').then((mod) => mod.PayButton),
|
||||
{
|
||||
ssr: false,
|
||||
}
|
||||
);
|
||||
|
||||
export default function CourseDetails({ processedEvent }) {
|
||||
const [author, setAuthor] = useState(null);
|
||||
const [bitcoinConnect, setBitcoinConnect] = useState(false);
|
||||
const [nAddress, setNAddress] = useState(null);
|
||||
const [zapAmount, setZapAmount] = useState(0);
|
||||
const [user, setUser] = useState(null);
|
||||
@ -46,15 +38,6 @@ export default function CourseDetails({ processedEvent }) {
|
||||
}
|
||||
}, [session]);
|
||||
|
||||
const handleZapEvent = async () => {
|
||||
if (!processedEvent) return;
|
||||
|
||||
// Update zap event logic if necessary for NDK
|
||||
const response = await zapEvent(processedEvent);
|
||||
|
||||
console.log('zap response:', response);
|
||||
};
|
||||
|
||||
const fetchAuthor = useCallback(async (pubkey) => {
|
||||
if (!pubkey) return;
|
||||
const author = await ndk.getUser({ pubkey });
|
||||
@ -65,16 +48,6 @@ export default function CourseDetails({ processedEvent }) {
|
||||
}
|
||||
}, [ndk]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
const bitcoinConnectConfig = window.localStorage.getItem('bc:config');
|
||||
|
||||
if (bitcoinConnectConfig) {
|
||||
setBitcoinConnect(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (processedEvent) {
|
||||
fetchAuthor(processedEvent.pubkey);
|
||||
@ -141,15 +114,9 @@ export default function CourseDetails({ processedEvent }) {
|
||||
height={194}
|
||||
className="w-[344px] h-[194px] object-cover object-top rounded-lg"
|
||||
/>
|
||||
{bitcoinConnect ? (
|
||||
<div>
|
||||
<BitcoinConnectPayButton onClick={handleZapEvent} />
|
||||
</div>
|
||||
) : (
|
||||
<div className='w-full flex justify-end'>
|
||||
<ZapDisplay zapAmount={zapAmount} event={processedEvent} zapsLoading={zapsLoading} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
@ -7,13 +7,6 @@ import ZapDisplay from "@/components/zaps/ZapDisplay";
|
||||
import dynamic from "next/dynamic";
|
||||
import { useZapsQuery } from "@/hooks/nostrQueries/zaps/useZapsQuery";
|
||||
|
||||
const BitcoinConnectPayButton = dynamic(
|
||||
() => import('@getalby/bitcoin-connect-react').then((mod) => mod.PayButton),
|
||||
{
|
||||
ssr: false,
|
||||
}
|
||||
);
|
||||
|
||||
const MDDisplay = dynamic(
|
||||
() => import("@uiw/react-markdown-preview"),
|
||||
{
|
||||
@ -22,26 +15,11 @@ const MDDisplay = dynamic(
|
||||
);
|
||||
|
||||
const CourseLesson = ({ lesson, course }) => {
|
||||
const [bitcoinConnect, setBitcoinConnect] = useState(false);
|
||||
const [zapAmount, setZapAmount] = useState(0);
|
||||
|
||||
const { zaps, zapsLoading, zapsError } = useZapsQuery({ event: lesson, type: "lesson" });
|
||||
const { returnImageProxy } = useImageProxy();
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
const bitcoinConnectConfig = window.localStorage.getItem('bc:config');
|
||||
|
||||
if (bitcoinConnectConfig) {
|
||||
setBitcoinConnect(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleZapEvent = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!zaps || zapsLoading || zapsError) return;
|
||||
|
||||
@ -90,15 +68,9 @@ const CourseLesson = ({ lesson, course }) => {
|
||||
height={194}
|
||||
className="w-[344px] h-[194px] object-cover object-top rounded-lg"
|
||||
/>
|
||||
{bitcoinConnect ? (
|
||||
<div>
|
||||
<BitcoinConnectPayButton onClick={handleZapEvent} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full flex justify-end">
|
||||
<ZapDisplay zapAmount={zapAmount} event={lesson} zapsLoading={zapsLoading} />
|
||||
</div>
|
||||
)}
|
||||
<div className="w-full flex justify-end">
|
||||
<ZapDisplay zapAmount={zapAmount} event={lesson} zapsLoading={zapsLoading} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
@ -115,12 +115,12 @@ export default function DraftCourseDetails({ processedEvent, draftId, lessons })
|
||||
await axios.delete(`/api/courses/drafts/${processedEvent.id}`);
|
||||
|
||||
// Step 6: Show success message and redirect
|
||||
showToast('success', 'Course created successfully');
|
||||
showToast('success', 'Success', 'Course created successfully');
|
||||
router.push(`/course/${courseEvent.id}`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error creating course:', error);
|
||||
showToast('error', error.message || 'Failed to create course. Please try again.');
|
||||
showToast('error', 'Error', error.message || 'Failed to create course. Please try again.');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,15 @@ const ContentListItem = (content) => {
|
||||
const { returnImageProxy } = useImageProxy();
|
||||
const router = useRouter();
|
||||
const isDraft = Object.keys(content).includes('type');
|
||||
const isCourse = content && content?.resources && content?.resources?.length > 0;
|
||||
const isCourse = content && content?.kind === 30004;
|
||||
|
||||
useEffect(() => {
|
||||
if (content && content?.kind === 30004) {
|
||||
console.log("isDraft", isDraft);
|
||||
console.log("content", content);
|
||||
console.log("isCourse", isCourse);
|
||||
}
|
||||
}, [content, isDraft, isCourse]);
|
||||
|
||||
const handleClick = () => {
|
||||
let path = '';
|
||||
@ -21,8 +29,8 @@ const ContentListItem = (content) => {
|
||||
path = '/details';
|
||||
}
|
||||
|
||||
const draftSuffix = isCourse ? '/draft' : '';
|
||||
const fullPath = `${path}/${content.id}${draftSuffix}`;
|
||||
// const draftSuffix = isCourse ? '/draft' : '';
|
||||
const fullPath = `${path}/${content.id}`;
|
||||
|
||||
router.push(fullPath);
|
||||
};
|
||||
|
@ -2,7 +2,7 @@ import React, { useEffect, useState, useCallback } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import { parseCourseEvent, parseEvent, findKind0Fields } from "@/utils/nostr";
|
||||
import CourseDetails from "@/components/content/courses/CourseDetails";
|
||||
import CourseLesson from "@/components/courses/CourseLesson";
|
||||
import CourseLesson from "@/components/content/courses/CourseLesson";
|
||||
import dynamic from 'next/dynamic';
|
||||
import { useNDKContext } from "@/context/NDKContext";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user