From 579659207e6d1405bf2fcd8bf0b644acedd2fd1a Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Mon, 16 Sep 2024 10:25:51 +0000 Subject: [PATCH 1/4] fix some code details --- src/common/services/breathecode.js | 2 +- src/js_modules/chooseProgram/index.jsx | 174 ++++++++++++------------- 2 files changed, 87 insertions(+), 89 deletions(-) diff --git a/src/common/services/breathecode.js b/src/common/services/breathecode.js index 2e2612ecd..a83f1463b 100644 --- a/src/common/services/breathecode.js +++ b/src/common/services/breathecode.js @@ -286,6 +286,7 @@ const breathecode = { const qs = parseQuerys(query); return { lead: (data) => axios.post(`${url}/lead${qs}`, data), + courses: () => axios.get(`${url}/course${qs}`), }; }, @@ -324,7 +325,6 @@ const breathecode = { return { checking: (data) => axios.put(`${url}/checking${qs}`, data), subscriptions: () => axios.get(`${url}/me/subscription${qs}`), - courses: () => axios.get(`${host}/marketing/course${qs}`), pay: (data) => breathecode.post(`${url}/pay${qs}`, data), addCard: (data) => breathecode.post(`${url}/card${qs}`, data), cancelSubscription: (id) => axios.put(`${url}/subscription/${id}/cancel${qs}`), diff --git a/src/js_modules/chooseProgram/index.jsx b/src/js_modules/chooseProgram/index.jsx index 0b04be4e0..a1e318a00 100644 --- a/src/js_modules/chooseProgram/index.jsx +++ b/src/js_modules/chooseProgram/index.jsx @@ -45,16 +45,16 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { }); }) : []; - const marketingCourses = marketingCursesList?.length > 0 ? marketingCursesList.filter( + const marketingCourses = marketingCursesList.filter( (item) => !activeSubscriptionCohorts.some( (activeCohort) => activeCohort?.all_subscriptions?.some( (sb) => sb?.selected_cohort_set?.slug === item?.slug, ), ) && item?.course_translation?.title, - ) : []; + ); - const isNotAvailableForMktCourses = activeSubscriptionCohorts.length > 0 && activeSubscriptionCohorts.some( - (item) => item?.cohort?.available_as_saas === false, + const isNotAvailableForMktCourses = activeSubscriptionCohorts.some( + (item) => item.cohort?.available_as_saas === false, ); useEffect(() => { @@ -62,7 +62,7 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { }, [router.locale]); useEffect(() => { - bc.payment({ academy: WHITE_LABEL_ACADEMY }).courses() + bc.marketing({ academy: WHITE_LABEL_ACADEMY }).courses() .then(({ data }) => { setMarketingCursesList(data); }); @@ -71,35 +71,35 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { return ( <> {activeSubscriptionCohorts.length > 0 && ( - - - {t('your-active-programs')} - - - + <> + + + {t('your-active-programs')} + + + + 1 ? cardColumnSize : '', md: cardColumnSize }} + height="auto" + gridGap="4rem" + > + {activeSubscriptionCohorts.map((item) => ( + setUpgradeModalIsOpen(true)} + setLateModalProps={setLateModalProps} + /> + ))} + + )} setUpgradeModalIsOpen(false)} /> - {activeSubscriptionCohorts.length > 0 && ( - 1 ? cardColumnSize : '', md: cardColumnSize }} - height="auto" - gridGap="4rem" - > - {activeSubscriptionCohorts.map((item) => ( - setUpgradeModalIsOpen(true)} - setLateModalProps={setLateModalProps} - /> - ))} - - )} {!isNotAvailableForMktCourses && marketingCourses?.length > 0 && marketingCourses.some((l) => l?.course_translation?.title) && ( <> @@ -133,67 +133,65 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { )} - { - finishedCohorts.length > 0 && ( - <> - 0 && ( + <> + + - - {isPlural(finishedCohorts) - ? t('finished.plural', { finishedCohorts: finishedCohorts.length }) - : t('finished.singular', { finishedCohorts: finishedCohorts.length })} - - setShowFinished(!showFinished)} - > - {showFinished ? t('finished.hide') : t('finished.show')} - - - - + setShowFinished(!showFinished)} > - {showFinished && finishedCohorts.map((item) => ( - setUpgradeModalIsOpen(true)} - /> - ))} - - - ) - } + {showFinished ? t('finished.hide') : t('finished.show')} + + + + + {showFinished && finishedCohorts.map((item) => ( + setUpgradeModalIsOpen(true)} + /> + ))} + + + )} ); } From f1e17e0c4e9fa1e2c828b86cffba6f4e49c1d05b Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Tue, 17 Sep 2024 08:46:53 +0000 Subject: [PATCH 2/4] hide saas courses for non saas students --- src/js_modules/chooseProgram/index.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js_modules/chooseProgram/index.jsx b/src/js_modules/chooseProgram/index.jsx index a1e318a00..00a90b65d 100644 --- a/src/js_modules/chooseProgram/index.jsx +++ b/src/js_modules/chooseProgram/index.jsx @@ -45,6 +45,8 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { }); }) : []; + const hasNonSaasCourse = chooseList.some(({ cohort }) => !cohort.available_as_saas); + const marketingCourses = marketingCursesList.filter( (item) => !activeSubscriptionCohorts.some( (activeCohort) => activeCohort?.all_subscriptions?.some( @@ -68,6 +70,12 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { }); }, [router?.locale]); + const filterForNonSaasStudents = (course) => { + if (!hasNonSaasCourse) return true; + + return course.plan_slug === process.env.BASE_PLAN; + }; + return ( <> {activeSubscriptionCohorts.length > 0 && ( @@ -101,7 +109,7 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { onClose={() => setUpgradeModalIsOpen(false)} /> - {!isNotAvailableForMktCourses && marketingCourses?.length > 0 && marketingCourses.some((l) => l?.course_translation?.title) && ( + {!isNotAvailableForMktCourses && marketingCourses.some((l) => l?.course_translation?.title) && ( <> @@ -115,7 +123,7 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { height="auto" gridGap="4rem" > - {marketingCourses.map((item) => ( + {marketingCourses.filter(filterForNonSaasStudents).map((item) => ( Date: Thu, 19 Sep 2024 11:59:45 +0000 Subject: [PATCH 3/4] fix details --- src/js_modules/chooseProgram/index.jsx | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/js_modules/chooseProgram/index.jsx b/src/js_modules/chooseProgram/index.jsx index 00a90b65d..487dc1dc7 100644 --- a/src/js_modules/chooseProgram/index.jsx +++ b/src/js_modules/chooseProgram/index.jsx @@ -23,13 +23,12 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { const [marketingCursesList, setMarketingCursesList] = useState([]); const [showFinished, setShowFinished] = useState(false); const [upgradeModalIsOpen, setUpgradeModalIsOpen] = useState(false); - const activeCohorts = handlers.getActiveCohorts(chooseList); - const finishedCohorts = handlers.getCohortsFinished(chooseList); const { featuredColor } = useStyle(); const router = useRouter(); - const cardColumnSize = 'repeat(auto-fill, minmax(17rem, 1fr))'; - const activeSubscriptionCohorts = activeCohorts?.length > 0 ? activeCohorts.map((item) => { + + const finishedCohorts = handlers.getCohortsFinished(chooseList); + const activeCohorts = handlers.getActiveCohorts(chooseList).map((item) => { const cohort = item?.cohort; const currentCohortProps = programsList[cohort.slug]; return ({ @@ -43,22 +42,16 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { all_subscriptions: currentCohortProps?.all_subscriptions, subscription_exists: currentCohortProps?.subscription !== null || currentCohortProps?.plan_financing !== null, }); - }) : []; + }); const hasNonSaasCourse = chooseList.some(({ cohort }) => !cohort.available_as_saas); const marketingCourses = marketingCursesList.filter( - (item) => !activeSubscriptionCohorts.some( - (activeCohort) => activeCohort?.all_subscriptions?.some( - (sb) => sb?.selected_cohort_set?.slug === item?.slug, - ), + (item) => !activeCohorts.some( + (activeCohort) => activeCohort.slug === item?.cohort?.slug, ) && item?.course_translation?.title, ); - const isNotAvailableForMktCourses = activeSubscriptionCohorts.some( - (item) => item.cohort?.available_as_saas === false, - ); - useEffect(() => { axiosInstance.defaults.headers.common['Accept-Language'] = router.locale; }, [router.locale]); @@ -78,7 +71,7 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { return ( <> - {activeSubscriptionCohorts.length > 0 && ( + {activeCohorts.length > 0 && ( <> @@ -88,11 +81,11 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { 1 ? cardColumnSize : '', md: cardColumnSize }} + gridTemplateColumns={{ base: activeCohorts.length > 1 ? cardColumnSize : '', md: cardColumnSize }} height="auto" gridGap="4rem" > - {activeSubscriptionCohorts.map((item) => ( + {activeCohorts.map((item) => ( setUpgradeModalIsOpen(false)} /> - {!isNotAvailableForMktCourses && marketingCourses.some((l) => l?.course_translation?.title) && ( + {marketingCourses?.length > 0 && ( <> From d144c7b13d34e06ca40ff54a6587b4e3ca4c5795 Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Thu, 19 Sep 2024 13:30:12 +0000 Subject: [PATCH 4/4] fix detail --- src/js_modules/chooseProgram/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js_modules/chooseProgram/index.jsx b/src/js_modules/chooseProgram/index.jsx index 487dc1dc7..4eba9cac1 100644 --- a/src/js_modules/chooseProgram/index.jsx +++ b/src/js_modules/chooseProgram/index.jsx @@ -48,7 +48,7 @@ function ChooseProgram({ chooseList, handleChoose, setLateModalProps }) { const marketingCourses = marketingCursesList.filter( (item) => !activeCohorts.some( - (activeCohort) => activeCohort.slug === item?.cohort?.slug, + ({ cohort }) => cohort.slug === item?.cohort?.slug, ) && item?.course_translation?.title, );