From 2e57cdf70fdaccf1192eff2278053d24fb3f903b Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez Date: Mon, 16 Dec 2024 13:52:40 -0400 Subject: [PATCH 1/6] Allow getting the info from landing_variables --- src/pages/bootcamp/[course_slug].jsx | 33 +++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/pages/bootcamp/[course_slug].jsx b/src/pages/bootcamp/[course_slug].jsx index b3c7b041c..09c4b61d3 100644 --- a/src/pages/bootcamp/[course_slug].jsx +++ b/src/pages/bootcamp/[course_slug].jsx @@ -258,6 +258,23 @@ function CoursePage({ data }) { }; const featurePrice = getPlanPrice().toLocaleLowerCase(); + const getAlternativeTranslation = (slug) => { + const keys = slug.split('.'); + let result = data?.course_translation?.landing_variables; + + if (!result) return t(slug); + + for (const key of keys) { + if (result[key] !== undefined) { + result = result[key]; + } else { + return t(slug); // Return the value from t() function if the slug doesn't exist in data.landing_variables + } + } + + return result; + }; + useEffect(() => { if (isRigoInitialized && data.course_translation && !initialDataIsFetching) { const context = document.body.innerText; @@ -911,11 +928,11 @@ function CoursePage({ data }) { Date: Mon, 16 Dec 2024 13:53:11 -0400 Subject: [PATCH 2/6] Allow getting the info from landing_variables --- src/pages/pricing.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/pricing.jsx b/src/pages/pricing.jsx index e6334e58b..ecc97665d 100644 --- a/src/pages/pricing.jsx +++ b/src/pages/pricing.jsx @@ -336,9 +336,9 @@ function PricingView() { {t('see-plans-and-prices')} - {course?.course_translation?.landing_variables?.length > 0 && ( + {course?.course_translation?.landing_variables?.card?.length > 0 && ( - {course?.course_translation?.landing_variables.map((content) => { + {course?.course_translation?.landing_variables?.card?.map((content) => { const isUrlImage = content?.icon?.includes('http'); return ( From 3f9b45a95dc21e042f7843c29d501c172c9946ec Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez Date: Mon, 16 Dec 2024 13:53:18 -0400 Subject: [PATCH 3/6] Allow getting the info from landing_variables --- src/pages/bootcamp/[course_slug].jsx | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/pages/bootcamp/[course_slug].jsx b/src/pages/bootcamp/[course_slug].jsx index 09c4b61d3..648e35745 100644 --- a/src/pages/bootcamp/[course_slug].jsx +++ b/src/pages/bootcamp/[course_slug].jsx @@ -587,13 +587,13 @@ function CoursePage({ data }) { ) : ( <> - {!isVisibilityPublic ? t('title-connectors.learning') : t('title-connectors.start')} + {!isVisibilityPublic ? getAlternativeTranslation('title-connectors.learning') : getAlternativeTranslation('title-connectors.start')} {data?.course_translation?.title} - {!isVisibilityPublic ? t('title-connectors.own-pace') : t('title-connectors.end')} + {!isVisibilityPublic ? getAlternativeTranslation('title-connectors.own-pace') : getAlternativeTranslation('title-connectors.end')} ) @@ -639,7 +639,7 @@ function CoursePage({ data }) { : ( - {students.length > limitViewStudents ? t('students-enrolled-count', { count: students.length - limitViewStudents }) : ''} + {students.length > limitViewStudents ? getAlternativeTranslation('students-enrolled-count', { count: students.length - limitViewStudents }) : ''} )} @@ -677,9 +677,9 @@ function CoursePage({ data }) { joinCohort()} > - {t('join-cohort')} + {getAlternativeTranslation('join-cohort')} ) : ( <> @@ -734,7 +734,7 @@ function CoursePage({ data }) { }} > {!featuredPlanToEnroll?.isFreeTier - ? `${t('common:enroll-for-connector')} ${featurePrice}` + ? `${getAlternativeTranslation('common:enroll-for-connector')} ${featurePrice}` : capitalizeFirstLetter(featurePrice)} {payableList?.length > 0 && ( @@ -803,14 +803,14 @@ function CoursePage({ data }) { tryRigobot('#try-rigobot')} - buttonText={t('rigobot.button')} + buttonText={getAlternativeTranslation('rigobot.button')} buttonProps={{ id: 'try-rigobot' }} > - {t('rigobot.description')} + {getAlternativeTranslation('rigobot.description')} @@ -824,14 +824,14 @@ function CoursePage({ data }) { )} - {t('build-connector.what-you-will')} + {getAlternativeTranslation('build-connector.what-you-will')} {' '} - {t('build-connector.build')} + {getAlternativeTranslation('build-connector.build')} - {t('build-connector.description')} + {getAlternativeTranslation('build-connector.description')} {assignmentList?.length > 0 && assignmentList.slice(0, 3).map((item) => { @@ -872,13 +872,13 @@ function CoursePage({ data }) { - {t('why-learn-4geeks-connector.why-learn-with')} + {getAlternativeTranslation('why-learn-4geeks-connector.why-learn-with')} {' '} 4Geeks ? - {t('why-learn-4geeks-connector.benefits-connector')} + {getAlternativeTranslation('why-learn-4geeks-connector.benefits-connector')} @@ -927,11 +927,11 @@ function CoursePage({ data }) { @@ -988,8 +988,8 @@ function CoursePage({ data }) { {/* FAQ section */} From 3babb4370d32de7785195cc96c9542b1d3c5f2cb Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez Date: Mon, 16 Dec 2024 15:29:23 -0400 Subject: [PATCH 4/6] Fix deployment issues --- src/pages/bootcamp/[course_slug].jsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/pages/bootcamp/[course_slug].jsx b/src/pages/bootcamp/[course_slug].jsx index 648e35745..2e49568c5 100644 --- a/src/pages/bootcamp/[course_slug].jsx +++ b/src/pages/bootcamp/[course_slug].jsx @@ -260,19 +260,11 @@ function CoursePage({ data }) { const getAlternativeTranslation = (slug) => { const keys = slug.split('.'); - let result = data?.course_translation?.landing_variables; - - if (!result) return t(slug); - - for (const key of keys) { - if (result[key] !== undefined) { - result = result[key]; - } else { - return t(slug); // Return the value from t() function if the slug doesn't exist in data.landing_variables - } - } + const result = keys.reduce((acc, key) => { + return acc && acc[key] !== undefined ? acc[key] : null; + }, data?.course_translation?.landing_variables); - return result; + return result !== null ? result : t(slug); }; useEffect(() => { From eaef7966466e7ca1210590bd7a77ba24f1e81b40 Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez Date: Mon, 16 Dec 2024 15:39:10 -0400 Subject: [PATCH 5/6] Fix deployment issues --- src/pages/bootcamp/[course_slug].jsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/bootcamp/[course_slug].jsx b/src/pages/bootcamp/[course_slug].jsx index 2e49568c5..913310338 100644 --- a/src/pages/bootcamp/[course_slug].jsx +++ b/src/pages/bootcamp/[course_slug].jsx @@ -260,10 +260,8 @@ function CoursePage({ data }) { const getAlternativeTranslation = (slug) => { const keys = slug.split('.'); - const result = keys.reduce((acc, key) => { - return acc && acc[key] !== undefined ? acc[key] : null; - }, data?.course_translation?.landing_variables); - + const result = keys.reduce((acc, key) => acc && acc[key] !== undefined ? acc[key] : null, data?.course_translation?.landing_variables); + return result !== null ? result : t(slug); }; From 8c70746cc068a02b470e2f877550ee41c331d4f2 Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez Date: Mon, 16 Dec 2024 15:44:32 -0400 Subject: [PATCH 6/6] Fix deployment issues --- src/pages/bootcamp/[course_slug].jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/bootcamp/[course_slug].jsx b/src/pages/bootcamp/[course_slug].jsx index 913310338..fa29ca865 100644 --- a/src/pages/bootcamp/[course_slug].jsx +++ b/src/pages/bootcamp/[course_slug].jsx @@ -260,7 +260,10 @@ function CoursePage({ data }) { const getAlternativeTranslation = (slug) => { const keys = slug.split('.'); - const result = keys.reduce((acc, key) => acc && acc[key] !== undefined ? acc[key] : null, data?.course_translation?.landing_variables); + const result = keys.reduce((acc, key) => { + if (acc && acc[key] !== undefined) return acc[key]; + return null; + }, data?.course_translation?.landing_variables); return result !== null ? result : t(slug); };