mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-05 00:32:03 +00:00
no comments on whole course for now until course layout update, cleanup a bit
This commit is contained in:
parent
29e0445964
commit
4c291b5771
@ -6,4 +6,4 @@
|
|||||||
"printWidth": 100,
|
"printWidth": 100,
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"arrowParens": "avoid"
|
"arrowParens": "avoid"
|
||||||
}
|
}
|
@ -9,7 +9,6 @@ import {
|
|||||||
} from '@/components/ui/card';
|
} from '@/components/ui/card';
|
||||||
import { Tag } from 'primereact/tag';
|
import { Tag } from 'primereact/tag';
|
||||||
import ZapDisplay from '@/components/zaps/ZapDisplay';
|
import ZapDisplay from '@/components/zaps/ZapDisplay';
|
||||||
import ZapThreadsWrapper from '@/components/ZapThreadsWrapper';
|
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { useZapsSubscription } from '@/hooks/nostrQueries/zaps/useZapsSubscription';
|
import { useZapsSubscription } from '@/hooks/nostrQueries/zaps/useZapsSubscription';
|
||||||
@ -32,23 +31,12 @@ export function CourseTemplate({ course, showMetaTags = true }) {
|
|||||||
const [zapAmount, setZapAmount] = useState(0);
|
const [zapAmount, setZapAmount] = useState(0);
|
||||||
const [lessonCount, setLessonCount] = useState(0);
|
const [lessonCount, setLessonCount] = useState(0);
|
||||||
const [nAddress, setNAddress] = useState(null);
|
const [nAddress, setNAddress] = useState(null);
|
||||||
const [npub, setNpub] = useState(null);
|
|
||||||
const [nsec, setNsec] = useState(null);
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { returnImageProxy } = useImageProxy();
|
const { returnImageProxy } = useImageProxy();
|
||||||
const windowWidth = useWindowWidth();
|
const windowWidth = useWindowWidth();
|
||||||
const isMobile = windowWidth < 768;
|
const isMobile = windowWidth < 768;
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (session?.user?.privkey) {
|
|
||||||
const privkeyBuffer = Buffer.from(session.user.privkey, 'hex');
|
|
||||||
setNsec(nip19.nsecEncode(privkeyBuffer));
|
|
||||||
} else if (session?.user?.pubkey) {
|
|
||||||
setNpub(nip19.npubEncode(session.user.pubkey));
|
|
||||||
}
|
|
||||||
}, [session]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (zaps.length > 0) {
|
if (zaps.length > 0) {
|
||||||
const total = getTotalFromZaps(zaps, course);
|
const total = getTotalFromZaps(zaps, course);
|
||||||
@ -75,15 +63,6 @@ export function CourseTemplate({ course, showMetaTags = true }) {
|
|||||||
}
|
}
|
||||||
}, [course]);
|
}, [course]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (session?.user?.privkey) {
|
|
||||||
const privkeyBuffer = Buffer.from(session.user.privkey, 'hex');
|
|
||||||
setNsec(nip19.nsecEncode(privkeyBuffer));
|
|
||||||
} else if (session?.user?.pubkey) {
|
|
||||||
setNpub(nip19.npubEncode(session.user.pubkey));
|
|
||||||
}
|
|
||||||
}, [session]);
|
|
||||||
|
|
||||||
const shouldShowMetaTags = topic => {
|
const shouldShowMetaTags = topic => {
|
||||||
if (!showMetaTags) {
|
if (!showMetaTags) {
|
||||||
return !['lesson', 'document', 'video', 'course'].includes(topic);
|
return !['lesson', 'document', 'video', 'course'].includes(topic);
|
||||||
@ -204,29 +183,6 @@ export function CourseTemplate({ course, showMetaTags = true }) {
|
|||||||
className="items-center py-2"
|
className="items-center py-2"
|
||||||
/>
|
/>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
{nAddress !== null &&
|
|
||||||
(!course?.price ||
|
|
||||||
course.price === 0 ||
|
|
||||||
session?.user?.role?.subscribed ||
|
|
||||||
session?.user?.purchased?.some(purchase => purchase.resourceId === course.d)) && (
|
|
||||||
<div className="px-4 pb-4">
|
|
||||||
{nsec || npub ? (
|
|
||||||
<ZapThreadsWrapper
|
|
||||||
anchor={nAddress}
|
|
||||||
user={nsec || npub || null}
|
|
||||||
relays={appConfig.defaultRelayUrls.join(',')}
|
|
||||||
disable="zaps"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ZapThreadsWrapper
|
|
||||||
anchor={nAddress}
|
|
||||||
user={npub}
|
|
||||||
relays={appConfig.defaultRelayUrls.join(',')}
|
|
||||||
disable="zaps"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import WelcomeModal from '@/components/onboarding/WelcomeModal';
|
|||||||
import { ProgressSpinner } from 'primereact/progressspinner';
|
import { ProgressSpinner } from 'primereact/progressspinner';
|
||||||
import { Toast } from 'primereact/toast';
|
import { Toast } from 'primereact/toast';
|
||||||
import MoreOptionsMenu from '@/components/ui/MoreOptionsMenu';
|
import MoreOptionsMenu from '@/components/ui/MoreOptionsMenu';
|
||||||
import ZapThreadsWrapper from '@/components/ZapThreadsWrapper';
|
|
||||||
|
|
||||||
export default function CourseDetails({
|
export default function CourseDetails({
|
||||||
processedEvent,
|
processedEvent,
|
||||||
@ -121,15 +120,6 @@ export default function CourseDetails({
|
|||||||
}
|
}
|
||||||
}, [zaps, processedEvent]);
|
}, [zaps, processedEvent]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (session?.user?.privkey) {
|
|
||||||
const privkeyBuffer = Buffer.from(session.user.privkey, 'hex');
|
|
||||||
setNsec(nip19.nsecEncode(privkeyBuffer));
|
|
||||||
} else if (session?.user?.pubkey) {
|
|
||||||
setNpub(nip19.npubEncode(session.user.pubkey));
|
|
||||||
}
|
|
||||||
}, [session]);
|
|
||||||
|
|
||||||
const renderPaymentMessage = () => {
|
const renderPaymentMessage = () => {
|
||||||
if (session?.user && session.user?.role?.subscribed && decryptionPerformed) {
|
if (session?.user && session.user?.role?.subscribed && decryptionPerformed) {
|
||||||
return (
|
return (
|
||||||
@ -278,40 +268,6 @@ export default function CourseDetails({
|
|||||||
</div>
|
</div>
|
||||||
<div className="w-full mt-4">{renderPaymentMessage()}</div>
|
<div className="w-full mt-4">{renderPaymentMessage()}</div>
|
||||||
</div>
|
</div>
|
||||||
{nAddress !== null && (
|
|
||||||
<div className="px-4">
|
|
||||||
{paidCourse ? (
|
|
||||||
// For paid content, only show ZapThreads if user has access
|
|
||||||
processedEvent?.pubkey === session?.user?.pubkey ||
|
|
||||||
decryptionPerformed ||
|
|
||||||
session?.user?.role?.subscribed ? (
|
|
||||||
<ZapThreadsWrapper
|
|
||||||
anchor={nAddress}
|
|
||||||
user={session?.user ? nsec || npub : null}
|
|
||||||
relays={appConfig.defaultRelayUrls.join(',')}
|
|
||||||
disable="zaps"
|
|
||||||
isAuthorized={true}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="text-center p-4 bg-gray-800/50 rounded-lg">
|
|
||||||
<p className="text-gray-400">
|
|
||||||
Comments are only available to course purchasers, subscribers, and the course
|
|
||||||
creator.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
// For free content, show ZapThreads to everyone
|
|
||||||
<ZapThreadsWrapper
|
|
||||||
anchor={nAddress}
|
|
||||||
user={session?.user ? nsec || npub : null}
|
|
||||||
relays={appConfig.defaultRelayUrls.join(',')}
|
|
||||||
disable="zaps"
|
|
||||||
isAuthorized={true}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user