diff --git a/apps/store/src/components/LayoutWithMenu/LayoutWithMenu.tsx b/apps/store/src/components/LayoutWithMenu/LayoutWithMenu.tsx index d479901c67..dc59cae634 100644 --- a/apps/store/src/components/LayoutWithMenu/LayoutWithMenu.tsx +++ b/apps/store/src/components/LayoutWithMenu/LayoutWithMenu.tsx @@ -6,6 +6,7 @@ import { HeaderBlock } from '@/blocks/HeaderBlock' import { ReusableBlockReference } from '@/blocks/ReusableBlockReference' import { PageStory, StoryblokPageProps } from '@/services/storyblok/storyblok' import { filterByBlockType, isProductStory } from '@/services/storyblok/Storyblok.helpers' +import { useHydrateTrustpilotData } from '@/services/trustpilot/trustpilot' import { useChangeLocale } from '@/utils/l10n/useChangeLocale' import { BreadcrumbList, BreadcrumbListItem } from './BreadcrumbList' import { GlobalProductMetadata, GLOBAL_PRODUCT_METADATA_PROP_NAME } from './fetchProductMetadata' @@ -33,6 +34,8 @@ export const LayoutWithMenu = (props: LayoutWithMenuProps) => { const { story, globalStory, className, breadcrumbs } = props.children.props useHydrateProductMetadata(props.children.props[GLOBAL_PRODUCT_METADATA_PROP_NAME]) + useHydrateTrustpilotData(props.children.props.trustpilot) + const handleLocaleChange = useChangeLocale(story) // Announcements are added as reusable blocks for Page and ProductPage content types diff --git a/apps/store/src/components/ProductPage/ProductPage.types.ts b/apps/store/src/components/ProductPage/ProductPage.types.ts index 7e151e88bc..f3d187017a 100644 --- a/apps/store/src/components/ProductPage/ProductPage.types.ts +++ b/apps/store/src/components/ProductPage/ProductPage.types.ts @@ -1,6 +1,7 @@ import { ProductDataQuery } from '@/services/apollo/generated' import { Template } from '@/services/PriceCalculator/PriceCalculator.types' import { ProductStory, StoryblokPageProps } from '@/services/storyblok/storyblok' +import { type TrustpilotData } from '@/services/trustpilot/trustpilot.types' export type ProductData = Exclude @@ -13,4 +14,5 @@ export type ProductPageProps = StoryblokPageProps & { priceTemplate: Template productData: ProductData initialSelectedVariant?: ProductDataVariant + trustpilot: TrustpilotData | null } diff --git a/apps/store/src/pages/[[...slug]].tsx b/apps/store/src/pages/[[...slug]].tsx index 4bbf5a05ad..33ad5a9681 100644 --- a/apps/store/src/pages/[[...slug]].tsx +++ b/apps/store/src/pages/[[...slug]].tsx @@ -26,6 +26,7 @@ import { } from '@/services/storyblok/storyblok' import { GLOBAL_STORY_PROP_NAME, STORY_PROP_NAME } from '@/services/storyblok/Storyblok.constant' import { isProductStory } from '@/services/storyblok/Storyblok.helpers' +import { fetchTrustpilotData } from '@/services/trustpilot/trustpilot' import { isRoutingLocale } from '@/utils/l10n/localeUtils' type NextContentPageProps = StoryblokPageProps & { type: 'content' } @@ -75,11 +76,12 @@ export const getStaticProps: GetStaticProps = a const timerName = `Get static props for ${locale}/${slug} ${draftMode ? '(draft)' : ''}` console.time(timerName) const version = draftMode ? 'draft' : 'published' - const [globalStory, translations, productMetadata, breadcrumbs] = await Promise.all([ + const [globalStory, translations, productMetadata, breadcrumbs, trustpilot] = await Promise.all([ getGlobalStory({ version, locale }), serverSideTranslations(locale), fetchGlobalProductMetadata({ apolloClient }), fetchBreadcrumbs(slug, { version, locale }), + fetchTrustpilotData(), ]).catch((error) => { throw new Error(`Failed to fetch data for ${slug}: ${error.message}`, { cause: error }) }) @@ -101,6 +103,7 @@ export const getStaticProps: GetStaticProps = a [GLOBAL_STORY_PROP_NAME]: globalStory, [GLOBAL_PRODUCT_METADATA_PROP_NAME]: productMetadata, breadcrumbs, + trustpilot, } const revalidate = process.env.VERCEL_ENV === 'preview' ? 1 : false diff --git a/apps/store/src/services/storyblok/storyblok.ts b/apps/store/src/services/storyblok/storyblok.ts index 880a56acc3..0fc3e05d07 100644 --- a/apps/store/src/services/storyblok/storyblok.ts +++ b/apps/store/src/services/storyblok/storyblok.ts @@ -72,6 +72,7 @@ import { blogBlocks } from '@/features/blog/blogBlocks' // TODO: get rid of this import, services should avoid feature-imports import { STORYBLOK_MANYPETS_FOLDER_SLUG } from '@/features/manyPets/manyPets.constants' import { manyPetsBlocks } from '@/features/manyPets/manyPetsBlocks' +import { TrustpilotData } from '@/services/trustpilot/trustpilot.types' import { isBrowser } from '@/utils/env' import { Features } from '@/utils/Features' import { getLocaleOrFallback, isRoutingLocale } from '@/utils/l10n/localeUtils' @@ -98,6 +99,7 @@ export type StoryblokQueryParams = { export type StoryblokPageProps = { [STORY_PROP_NAME]: PageStory [GLOBAL_STORY_PROP_NAME]: GlobalStory + trustpilot: TrustpilotData | null } export type StoryblokVersion = 'draft' | 'published'