diff --git a/src/components/bitcoinConnect/SubscriptionPaymentButton.js b/src/components/bitcoinConnect/SubscriptionPaymentButton.js index 87c8e39..27be3c9 100644 --- a/src/components/bitcoinConnect/SubscriptionPaymentButton.js +++ b/src/components/bitcoinConnect/SubscriptionPaymentButton.js @@ -73,14 +73,12 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio const handlePaymentSuccess = async (response) => { console.log('Payment successful', response); - clearInterval(checkPaymentInterval); showToast('success', 'Payment Successful', 'Your payment has been processed successfully.'); if (onSuccess) onSuccess(response); }; const handlePaymentError = async (error) => { console.error('Payment error', error); - clearInterval(checkPaymentInterval); showToast('error', 'Payment Failed', `An error occurred during payment: ${error.message}`); if (onError) onError(error); }; diff --git a/src/components/content/courses/CourseLesson.js b/src/components/content/courses/CourseLesson.js index f6cfc3d..9d510d3 100644 --- a/src/components/content/courses/CourseLesson.js +++ b/src/components/content/courses/CourseLesson.js @@ -16,10 +16,17 @@ const MDDisplay = dynamic( const CourseLesson = ({ lesson, course }) => { const [zapAmount, setZapAmount] = useState(0); - + const [paidResource, setPaidResource] = useState(false); + const [decryptedContent, setDecryptedContent] = useState(false); const { zaps, zapsLoading, zapsError } = useZapsQuery({ event: lesson, type: "lesson" }); const { returnImageProxy } = useImageProxy(); + useEffect(() => { + if (course.price) { + setPaidResource(true); + } + }, [course]); + useEffect(() => { if (!zaps || zapsLoading || zapsError) return; @@ -28,6 +35,19 @@ const CourseLesson = ({ lesson, course }) => { setZapAmount(total); }, [zaps, zapsLoading, zapsError, lesson]); + const renderContent = () => { + if (decryptedContent) { + return <MDDisplay className='p-4 rounded-lg w-full' source={decryptedContent} />; + } + if (paidResource && !decryptedContent) { + return <p className="text-center text-xl text-red-500">This content is paid and needs to be purchased before viewing.</p>; + } + if (lesson?.content) { + return <MDDisplay className='p-4 rounded-lg w-full' source={lesson.content} />; + } + return null; + } + return ( <div className='w-full px-24 pt-12 mx-auto mt-4 max-tab:px-0 max-mob:px-0 max-tab:pt-2 max-mob:pt-2'> <div className='w-full flex flex-row justify-between max-tab:flex-col max-mob:flex-col'> @@ -91,9 +111,7 @@ const CourseLesson = ({ lesson, course }) => { </div> </div> <div className='w-[75vw] mx-auto mt-12 p-12 border-t-2 border-gray-300 max-tab:p-0 max-mob:p-0 max-tab:max-w-[100vw] max-mob:max-w-[100vw]'> - { - lesson?.content && <MDDisplay className='p-4 rounded-lg' source={lesson.content} /> - } + {renderContent()} </div> </div> ) diff --git a/src/components/profile/subscription/SubscribeModal.js b/src/components/profile/subscription/SubscribeModal.js index de1dfd7..6a60097 100644 --- a/src/components/profile/subscription/SubscribeModal.js +++ b/src/components/profile/subscription/SubscribeModal.js @@ -78,6 +78,11 @@ const SubscribeModal = ({ user }) => { } }; + const onHide = () => { + setVisible(false); + setIsProcessing(false); + } + const menuItems = [ { label: "Renew Subscription", @@ -147,7 +152,7 @@ const SubscribeModal = ({ user }) => { <Dialog header="Subscribe to PlebDevs" visible={visible} - onHide={() => setVisible(false)} + onHide={onHide} className="p-fluid pb-0 w-fit" > {isProcessing ? (