From 4b4076675a24aa252643eb99c280187fdffc28fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matilda=20Landstr=C3=B6m?= Date: Fri, 12 Jul 2024 07:04:20 +0000 Subject: [PATCH] Merged in feat/use-translations-overview-table (pull request #342) fix: use translations for overview table Approved-by: Christel Westerberg --- .../ContentType/LoyaltyPage/LoyaltyPage.tsx | 4 +++- .../DynamicContent/OverviewTable/index.tsx | 5 +++-- .../Loyalty/Blocks/DynamicContent/index.tsx | 17 +++++++++-------- components/Loyalty/Blocks/WebView/index.tsx | 1 + components/Loyalty/Blocks/index.tsx | 4 +++- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/components/ContentType/LoyaltyPage/LoyaltyPage.tsx b/components/ContentType/LoyaltyPage/LoyaltyPage.tsx index 15307b984..dbd681e1f 100644 --- a/components/ContentType/LoyaltyPage/LoyaltyPage.tsx +++ b/components/ContentType/LoyaltyPage/LoyaltyPage.tsx @@ -22,7 +22,9 @@ export default async function LoyaltyPage({ lang }: LangParams) { {loyaltyPage.heading} - {loyaltyPage.blocks ? : null} + {loyaltyPage.blocks ? ( + + ) : null} ) diff --git a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx index e1594d97f..b76a0d4b6 100644 --- a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx +++ b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx @@ -33,6 +33,7 @@ import { OverviewTableProps, OverviewTableReducerAction, } from "@/types/components/loyalty/blocks" +import { LangParams } from "@/types/params" import type { User } from "@/types/user" const levelsTranslations = { @@ -126,9 +127,9 @@ function reducer(state: any, action: OverviewTableReducerAction) { export default function OverviewTable({ activeMembership, -}: OverviewTableProps) { + lang, +}: OverviewTableProps & LangParams) { const intl = useIntl() - const lang = Lang.en const levelsData = levelsTranslations[lang] const [selectionState, dispatch] = useReducer( reducer, diff --git a/components/Loyalty/Blocks/DynamicContent/index.tsx b/components/Loyalty/Blocks/DynamicContent/index.tsx index 235fe9ecc..24feb30d7 100644 --- a/components/Loyalty/Blocks/DynamicContent/index.tsx +++ b/components/Loyalty/Blocks/DynamicContent/index.tsx @@ -1,7 +1,5 @@ -import { Lang } from "@/constants/languages" import { serverClient } from "@/lib/trpc/server" -import { auth } from "@/auth" import SectionContainer from "@/components/Section/Container" import SectionHeader from "@/components/Section/Header" import SectionLink from "@/components/Section/Link" @@ -19,17 +17,20 @@ import type { DynamicContentProps, } from "@/types/components/loyalty/blocks" import { LoyaltyComponentEnum } from "@/types/components/loyalty/enums" +import { LangParams } from "@/types/params" -async function DynamicComponentBlock({ component }: DynamicComponentProps) { +async function DynamicComponentBlock({ + component, + lang, +}: DynamicComponentProps & LangParams) { const membershipLevel = await serverClient().user.membershipLevel() - switch (component) { case LoyaltyComponentEnum.how_it_works: return case LoyaltyComponentEnum.loyalty_levels: return case LoyaltyComponentEnum.overview_table: - return + return default: return null } @@ -38,13 +39,13 @@ async function DynamicComponentBlock({ component }: DynamicComponentProps) { export default function DynamicContent({ dynamicContent, firstItem, -}: DynamicContentProps) { + lang, +}: DynamicContentProps & LangParams) { const displayHeader = !!( dynamicContent.link || dynamicContent.subtitle || dynamicContent.title ) - const isOverviewTable = dynamicContent.component === LoyaltyComponentEnum.overview_table return ( @@ -62,7 +63,7 @@ export default function DynamicContent({ topTitle={firstItem} /> ) : null} - + {displayHeader && ( )} diff --git a/components/Loyalty/Blocks/WebView/index.tsx b/components/Loyalty/Blocks/WebView/index.tsx index 85a881142..a0f63d4f1 100644 --- a/components/Loyalty/Blocks/WebView/index.tsx +++ b/components/Loyalty/Blocks/WebView/index.tsx @@ -45,6 +45,7 @@ export function Blocks({ lang, blocks }: BlocksProps & LangParams) { dynamicContent={dynamicContent} firstItem={firstItem} key={`${block.dynamic_content.title}-${idx}`} + lang={lang} /> ) case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts: diff --git a/components/Loyalty/Blocks/index.tsx b/components/Loyalty/Blocks/index.tsx index c272026fa..6963db43f 100644 --- a/components/Loyalty/Blocks/index.tsx +++ b/components/Loyalty/Blocks/index.tsx @@ -6,8 +6,9 @@ import CardsGrid from "./CardsGrid" import type { BlocksProps } from "@/types/components/loyalty/blocks" import { LoyaltyBlocksTypenameEnum } from "@/types/components/loyalty/enums" +import { LangParams } from "@/types/params" -export function Blocks({ blocks }: BlocksProps) { +export function Blocks({ blocks, lang }: BlocksProps & LangParams) { return blocks.map((block, idx) => { const firstItem = idx === 0 switch (block.__typename) { @@ -26,6 +27,7 @@ export function Blocks({ blocks }: BlocksProps) { dynamicContent={block.dynamic_content} firstItem={firstItem} key={`${block.dynamic_content.title}-${idx}`} + lang={lang} /> ) case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts: