mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Fix small issue with subscription button flows, got started on paid course cleanup
This commit is contained in:
parent
b686f613b7
commit
aaad0d9931
@ -73,14 +73,12 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio
|
|||||||
|
|
||||||
const handlePaymentSuccess = async (response) => {
|
const handlePaymentSuccess = async (response) => {
|
||||||
console.log('Payment successful', response);
|
console.log('Payment successful', response);
|
||||||
clearInterval(checkPaymentInterval);
|
|
||||||
showToast('success', 'Payment Successful', 'Your payment has been processed successfully.');
|
showToast('success', 'Payment Successful', 'Your payment has been processed successfully.');
|
||||||
if (onSuccess) onSuccess(response);
|
if (onSuccess) onSuccess(response);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePaymentError = async (error) => {
|
const handlePaymentError = async (error) => {
|
||||||
console.error('Payment error', error);
|
console.error('Payment error', error);
|
||||||
clearInterval(checkPaymentInterval);
|
|
||||||
showToast('error', 'Payment Failed', `An error occurred during payment: ${error.message}`);
|
showToast('error', 'Payment Failed', `An error occurred during payment: ${error.message}`);
|
||||||
if (onError) onError(error);
|
if (onError) onError(error);
|
||||||
};
|
};
|
||||||
|
@ -16,10 +16,17 @@ const MDDisplay = dynamic(
|
|||||||
|
|
||||||
const CourseLesson = ({ lesson, course }) => {
|
const CourseLesson = ({ lesson, course }) => {
|
||||||
const [zapAmount, setZapAmount] = useState(0);
|
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 { zaps, zapsLoading, zapsError } = useZapsQuery({ event: lesson, type: "lesson" });
|
||||||
const { returnImageProxy } = useImageProxy();
|
const { returnImageProxy } = useImageProxy();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (course.price) {
|
||||||
|
setPaidResource(true);
|
||||||
|
}
|
||||||
|
}, [course]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!zaps || zapsLoading || zapsError) return;
|
if (!zaps || zapsLoading || zapsError) return;
|
||||||
|
|
||||||
@ -28,6 +35,19 @@ const CourseLesson = ({ lesson, course }) => {
|
|||||||
setZapAmount(total);
|
setZapAmount(total);
|
||||||
}, [zaps, zapsLoading, zapsError, lesson]);
|
}, [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 (
|
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 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'>
|
<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>
|
</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]'>
|
<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]'>
|
||||||
{
|
{renderContent()}
|
||||||
lesson?.content && <MDDisplay className='p-4 rounded-lg' source={lesson.content} />
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -78,6 +78,11 @@ const SubscribeModal = ({ user }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onHide = () => {
|
||||||
|
setVisible(false);
|
||||||
|
setIsProcessing(false);
|
||||||
|
}
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{
|
{
|
||||||
label: "Renew Subscription",
|
label: "Renew Subscription",
|
||||||
@ -147,7 +152,7 @@ const SubscribeModal = ({ user }) => {
|
|||||||
<Dialog
|
<Dialog
|
||||||
header="Subscribe to PlebDevs"
|
header="Subscribe to PlebDevs"
|
||||||
visible={visible}
|
visible={visible}
|
||||||
onHide={() => setVisible(false)}
|
onHide={onHide}
|
||||||
className="p-fluid pb-0 w-fit"
|
className="p-fluid pb-0 w-fit"
|
||||||
>
|
>
|
||||||
{isProcessing ? (
|
{isProcessing ? (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user