From 5116a3a888eb09f000d28533482cdc3aecd61ed3 Mon Sep 17 00:00:00 2001 From: MaryWylde Date: Mon, 2 Mar 2026 21:22:57 +0400 Subject: [PATCH] chore: fix locale issue and change apis --- src/api/longevity/about-project.ts | 2 +- src/api/longevity/diet.ts | 2 +- src/api/longevity/environment.ts | 3 ++- src/api/longevity/lifestyle.ts | 3 +-- src/api/longevity/study.ts | 3 ++- src/api/longevity/supplements.ts | 3 ++- .../longevity/WhatToEatOrAvoid/WhatToEatOrAvoid.tsx | 1 - src/pages/tools/longevity-protocol/habits/diet.tsx | 4 +++- src/pages/tools/longevity-protocol/habits/lifestyle.tsx | 3 ++- src/pages/tools/longevity-protocol/habits/sleep.tsx | 5 +++-- src/pages/tools/longevity-protocol/habits/workout.tsx | 3 ++- 11 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/api/longevity/about-project.ts b/src/api/longevity/about-project.ts index 05fb7ba..1b662fa 100644 --- a/src/api/longevity/about-project.ts +++ b/src/api/longevity/about-project.ts @@ -1,5 +1,5 @@ export async function getAboutProject(locale: string) { - const base = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-what-is-this`; + const base = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-about-project`; const currentLocale = locale === 'ru' ? 'ru' : 'en'; diff --git a/src/api/longevity/diet.ts b/src/api/longevity/diet.ts index 5fb9f52..7201c15 100644 --- a/src/api/longevity/diet.ts +++ b/src/api/longevity/diet.ts @@ -5,7 +5,7 @@ export async function getDiet(locale: string) { next: { revalidate: 3600 }, }); - if (!res.ok) throw new Error('Failed to fetch contributor'); + if (!res.ok) throw new Error('Failed to fetch Diet'); const json = await res.json(); const attrs = json?.data?.attributes ?? {}; diff --git a/src/api/longevity/environment.ts b/src/api/longevity/environment.ts index 3405a1f..395cbb1 100644 --- a/src/api/longevity/environment.ts +++ b/src/api/longevity/environment.ts @@ -1,5 +1,6 @@ export async function getEnvironment(locale: string) { - const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-environment?populate[home][populate]=icon&populate[principles][populate]=icon&populate[data_tracking][populate]=icon&[populate]=image&populate[OGTags][populate]=ogImage&populate=Seo&locale=${locale}`; + const chosenLocale = locale === 'ru' ? 'ru' : 'en'; + const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-environment?populate[home][populate]=icon&populate[principles][populate]=icon&populate[data_tracking][populate]=icon&[populate]=image&populate[OGTags][populate]=ogImage&populate=Seo&locale=${chosenLocale}`; const res = await fetch(url, { next: { revalidate: 3600 }, diff --git a/src/api/longevity/lifestyle.ts b/src/api/longevity/lifestyle.ts index 87a9b54..c1d62ad 100644 --- a/src/api/longevity/lifestyle.ts +++ b/src/api/longevity/lifestyle.ts @@ -1,6 +1,5 @@ export async function getLifestyleProtocol(locale: string) { - const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-habit-protocol?populate=*&locale=${locale}`; - + const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-lifestyle?populate=*&locale=${locale}`; const res = await fetch(url, { next: { revalidate: 3600 }, }); diff --git a/src/api/longevity/study.ts b/src/api/longevity/study.ts index 118f6fc..262ed50 100644 --- a/src/api/longevity/study.ts +++ b/src/api/longevity/study.ts @@ -1,5 +1,6 @@ export async function getStudy(locale: string) { - const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-study?populate=*&locale=${locale}`; + const chosenLocale = locale === 'ru' ? 'ru' : 'en'; + const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-study?populate=*&locale=${chosenLocale}`; const res = await fetch(url, { next: { revalidate: 3600 }, diff --git a/src/api/longevity/supplements.ts b/src/api/longevity/supplements.ts index 3b4e071..2f16406 100644 --- a/src/api/longevity/supplements.ts +++ b/src/api/longevity/supplements.ts @@ -1,5 +1,6 @@ export async function getSupplements(locale: string) { - const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-supplement?populate=*&locale=${locale}`; + const chosenLocale = locale === 'ru' ? 'ru' : 'en'; + const url = `${process.env.NEXT_PUBLIC_STRAPI}/api/longevity-supplement?populate=*&locale=${chosenLocale}`; const res = await fetch(url, { next: { revalidate: 3600 }, diff --git a/src/components/longevity/WhatToEatOrAvoid/WhatToEatOrAvoid.tsx b/src/components/longevity/WhatToEatOrAvoid/WhatToEatOrAvoid.tsx index bdfa260..1d59216 100644 --- a/src/components/longevity/WhatToEatOrAvoid/WhatToEatOrAvoid.tsx +++ b/src/components/longevity/WhatToEatOrAvoid/WhatToEatOrAvoid.tsx @@ -44,7 +44,6 @@ const WhatToEatOrAvoid: FC = ({ getPText(examples); setExampleContent(getPText(examples)); }, []); - console.log(selectedHealthyOptionId, ', id'); return (
{ export default Diet; export const getStaticProps: GetStaticProps = async ({ locale }) => { - const dietData = await getDiet(locale); + const chosenLocale = locale === 'ru' ? 'ru' : 'en'; + + const dietData = await getDiet(chosenLocale); return { props: { dietData }, diff --git a/src/pages/tools/longevity-protocol/habits/lifestyle.tsx b/src/pages/tools/longevity-protocol/habits/lifestyle.tsx index eddf810..aec581c 100644 --- a/src/pages/tools/longevity-protocol/habits/lifestyle.tsx +++ b/src/pages/tools/longevity-protocol/habits/lifestyle.tsx @@ -52,7 +52,8 @@ const Lifestyle = ({ habitsData }) => { export default Lifestyle; export const getStaticProps: GetStaticProps = async ({ locale }) => { - const habitsData = await getLifestyleProtocol(locale); + const chosenLocale = locale === 'ru' ? 'ru' : 'en'; + const habitsData = await getLifestyleProtocol(chosenLocale); return { props: { habitsData }, diff --git a/src/pages/tools/longevity-protocol/habits/sleep.tsx b/src/pages/tools/longevity-protocol/habits/sleep.tsx index 19d99f5..8c91942 100644 --- a/src/pages/tools/longevity-protocol/habits/sleep.tsx +++ b/src/pages/tools/longevity-protocol/habits/sleep.tsx @@ -52,8 +52,9 @@ const Sleep = ({ sleepData, sleepSupplements }) => { export default Sleep; export const getStaticProps: GetStaticProps = async ({ locale }) => { - const sleepData = await getSleep(locale); - const sleepSupplements = await getSleepSupplements(locale || 'en'); + const chosenLocale = locale === 'ru' ? 'ru' : 'en'; + const sleepData = await getSleep(chosenLocale); + const sleepSupplements = await getSleepSupplements(chosenLocale || 'en'); return { props: { sleepData, locale: locale ?? 'en', sleepSupplements }, diff --git a/src/pages/tools/longevity-protocol/habits/workout.tsx b/src/pages/tools/longevity-protocol/habits/workout.tsx index 980b8f0..08de77d 100644 --- a/src/pages/tools/longevity-protocol/habits/workout.tsx +++ b/src/pages/tools/longevity-protocol/habits/workout.tsx @@ -51,7 +51,8 @@ const Workout = ({ workoutData }) => { export default Workout; export const getStaticProps: GetStaticProps = async ({ locale }) => { - const workoutData = await getWorkout(locale); + const chosenLocale = locale === 'ru' ? 'ru' : 'en'; + const workoutData = await getWorkout(chosenLocale); return { props: { workoutData },