From 617d163c31f6e041ee27295e5fd326a76d0def0a Mon Sep 17 00:00:00 2001 From: lumi-tip Date: Fri, 13 Dec 2024 12:37:00 -0400 Subject: [PATCH] include epired courses --- src/common/store/actions/subscriptionAction.js | 2 +- src/pages/cohort/[cohortSlug]/[slug]/[version]/index.jsx | 8 +++++++- .../syllabus/[cohortSlug]/[lesson]/[lessonSlug]/index.jsx | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/common/store/actions/subscriptionAction.js b/src/common/store/actions/subscriptionAction.js index 23e8489e5..ba0ed383a 100644 --- a/src/common/store/actions/subscriptionAction.js +++ b/src/common/store/actions/subscriptionAction.js @@ -18,7 +18,7 @@ const useSubscriptionsHandler = () => { payload: true, }); bc.payment({ - status: 'ACTIVE,FREE_TRIAL,FULLY_PAID,CANCELLED,PAYMENT_ISSUE', + status: 'ACTIVE,FREE_TRIAL,FULLY_PAID,CANCELLED,PAYMENT_ISSUE,EXPIRED', }).subscriptions() .then(async ({ data }) => { const subscriptionsDataWithPlanOffer = data?.subscriptions?.length > 0 ? await Promise.all(data?.subscriptions.map(async (s) => { diff --git a/src/pages/cohort/[cohortSlug]/[slug]/[version]/index.jsx b/src/pages/cohort/[cohortSlug]/[slug]/[version]/index.jsx index 616145970..ceb9b1a14 100644 --- a/src/pages/cohort/[cohortSlug]/[slug]/[version]/index.jsx +++ b/src/pages/cohort/[cohortSlug]/[slug]/[version]/index.jsx @@ -208,6 +208,12 @@ function Dashboard() { return; } + const expiredCourse = cohortSubscriptions.find((sub) => sub.status === 'EXPIRED'); + if (expiredCourse) { + showToastAndRedirect(currentCohortSlug); + return; + } + const fullyPaidSub = cohortSubscriptions.find((sub) => sub.status === 'FULLY_PAID' || sub.status === 'ACTIVE'); if (fullyPaidSub) { setGrantAccess(true); @@ -276,7 +282,7 @@ function Dashboard() { }); bc.payment({ - status: 'ACTIVE,FREE_TRIAL,FULLY_PAID,CANCELLED,PAYMENT_ISSUE', + status: 'ACTIVE,FREE_TRIAL,FULLY_PAID,CANCELLED,PAYMENT_ISSUE,EXPIRED', }).subscriptions() .then(async ({ data }) => { const currentPlanFinancing = data?.plan_financings?.find((s) => s?.selected_cohort_set?.cohorts.some((cohort) => cohort?.slug === cohortSlug)); diff --git a/src/pages/syllabus/[cohortSlug]/[lesson]/[lessonSlug]/index.jsx b/src/pages/syllabus/[cohortSlug]/[lesson]/[lessonSlug]/index.jsx index 41a7fea24..f8bd18cbe 100644 --- a/src/pages/syllabus/[cohortSlug]/[lesson]/[lessonSlug]/index.jsx +++ b/src/pages/syllabus/[cohortSlug]/[lesson]/[lessonSlug]/index.jsx @@ -274,7 +274,7 @@ function SyllabusContent() { useEffect(() => { bc.payment({ - status: 'ACTIVE,FREE_TRIAL,FULLY_PAID,CANCELLED,PAYMENT_ISSUE', + status: 'ACTIVE,FREE_TRIAL,FULLY_PAID,CANCELLED,PAYMENT_ISSUE,EXPIRED', }).subscriptions() .then(async ({ data }) => { const planFinancings = data?.plan_financings?.length > 0 ? data?.plan_financings : []; @@ -309,6 +309,12 @@ function SyllabusContent() { return; } + const expiredCourse = cohortSubscriptions.find((sub) => sub.status === 'EXPIRED'); + if (expiredCourse) { + showToastAndRedirect(currentCohortSlug); + return; + } + const fullyPaidSub = cohortSubscriptions.find((sub) => sub.status === 'FULLY_PAID' || sub.status === 'ACTIVE'); if (fullyPaidSub) { setGrantAccess(true);