Merged in feat/use-translations-overview-table (pull request #342)
fix: use translations for overview table Approved-by: Christel Westerberg
This commit is contained in:
@@ -22,7 +22,9 @@ export default async function LoyaltyPage({ lang }: LangParams) {
|
|||||||
|
|
||||||
<MaxWidth className={styles.blocks} tag="main">
|
<MaxWidth className={styles.blocks} tag="main">
|
||||||
<Title>{loyaltyPage.heading}</Title>
|
<Title>{loyaltyPage.heading}</Title>
|
||||||
{loyaltyPage.blocks ? <Blocks blocks={loyaltyPage.blocks} /> : null}
|
{loyaltyPage.blocks ? (
|
||||||
|
<Blocks blocks={loyaltyPage.blocks} lang={lang} />
|
||||||
|
) : null}
|
||||||
</MaxWidth>
|
</MaxWidth>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
OverviewTableProps,
|
OverviewTableProps,
|
||||||
OverviewTableReducerAction,
|
OverviewTableReducerAction,
|
||||||
} from "@/types/components/loyalty/blocks"
|
} from "@/types/components/loyalty/blocks"
|
||||||
|
import { LangParams } from "@/types/params"
|
||||||
import type { User } from "@/types/user"
|
import type { User } from "@/types/user"
|
||||||
|
|
||||||
const levelsTranslations = {
|
const levelsTranslations = {
|
||||||
@@ -126,9 +127,9 @@ function reducer(state: any, action: OverviewTableReducerAction) {
|
|||||||
|
|
||||||
export default function OverviewTable({
|
export default function OverviewTable({
|
||||||
activeMembership,
|
activeMembership,
|
||||||
}: OverviewTableProps) {
|
lang,
|
||||||
|
}: OverviewTableProps & LangParams) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = Lang.en
|
|
||||||
const levelsData = levelsTranslations[lang]
|
const levelsData = levelsTranslations[lang]
|
||||||
const [selectionState, dispatch] = useReducer(
|
const [selectionState, dispatch] = useReducer(
|
||||||
reducer,
|
reducer,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { Lang } from "@/constants/languages"
|
|
||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
|
||||||
import { auth } from "@/auth"
|
|
||||||
import SectionContainer from "@/components/Section/Container"
|
import SectionContainer from "@/components/Section/Container"
|
||||||
import SectionHeader from "@/components/Section/Header"
|
import SectionHeader from "@/components/Section/Header"
|
||||||
import SectionLink from "@/components/Section/Link"
|
import SectionLink from "@/components/Section/Link"
|
||||||
@@ -19,17 +17,20 @@ import type {
|
|||||||
DynamicContentProps,
|
DynamicContentProps,
|
||||||
} from "@/types/components/loyalty/blocks"
|
} from "@/types/components/loyalty/blocks"
|
||||||
import { LoyaltyComponentEnum } from "@/types/components/loyalty/enums"
|
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()
|
const membershipLevel = await serverClient().user.membershipLevel()
|
||||||
|
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case LoyaltyComponentEnum.how_it_works:
|
case LoyaltyComponentEnum.how_it_works:
|
||||||
return <HowItWorks />
|
return <HowItWorks />
|
||||||
case LoyaltyComponentEnum.loyalty_levels:
|
case LoyaltyComponentEnum.loyalty_levels:
|
||||||
return <LoyaltyLevels />
|
return <LoyaltyLevels />
|
||||||
case LoyaltyComponentEnum.overview_table:
|
case LoyaltyComponentEnum.overview_table:
|
||||||
return <OverviewTable activeMembership={membershipLevel} />
|
return <OverviewTable activeMembership={membershipLevel} lang={lang} />
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -38,13 +39,13 @@ async function DynamicComponentBlock({ component }: DynamicComponentProps) {
|
|||||||
export default function DynamicContent({
|
export default function DynamicContent({
|
||||||
dynamicContent,
|
dynamicContent,
|
||||||
firstItem,
|
firstItem,
|
||||||
}: DynamicContentProps) {
|
lang,
|
||||||
|
}: DynamicContentProps & LangParams) {
|
||||||
const displayHeader = !!(
|
const displayHeader = !!(
|
||||||
dynamicContent.link ||
|
dynamicContent.link ||
|
||||||
dynamicContent.subtitle ||
|
dynamicContent.subtitle ||
|
||||||
dynamicContent.title
|
dynamicContent.title
|
||||||
)
|
)
|
||||||
|
|
||||||
const isOverviewTable =
|
const isOverviewTable =
|
||||||
dynamicContent.component === LoyaltyComponentEnum.overview_table
|
dynamicContent.component === LoyaltyComponentEnum.overview_table
|
||||||
return (
|
return (
|
||||||
@@ -62,7 +63,7 @@ export default function DynamicContent({
|
|||||||
topTitle={firstItem}
|
topTitle={firstItem}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<DynamicComponentBlock component={dynamicContent.component} />
|
<DynamicComponentBlock component={dynamicContent.component} lang={lang} />
|
||||||
{displayHeader && (
|
{displayHeader && (
|
||||||
<SectionLink link={dynamicContent.link} variant="mobile" />
|
<SectionLink link={dynamicContent.link} variant="mobile" />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export function Blocks({ lang, blocks }: BlocksProps & LangParams) {
|
|||||||
dynamicContent={dynamicContent}
|
dynamicContent={dynamicContent}
|
||||||
firstItem={firstItem}
|
firstItem={firstItem}
|
||||||
key={`${block.dynamic_content.title}-${idx}`}
|
key={`${block.dynamic_content.title}-${idx}`}
|
||||||
|
lang={lang}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ import CardsGrid from "./CardsGrid"
|
|||||||
|
|
||||||
import type { BlocksProps } from "@/types/components/loyalty/blocks"
|
import type { BlocksProps } from "@/types/components/loyalty/blocks"
|
||||||
import { LoyaltyBlocksTypenameEnum } from "@/types/components/loyalty/enums"
|
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) => {
|
return blocks.map((block, idx) => {
|
||||||
const firstItem = idx === 0
|
const firstItem = idx === 0
|
||||||
switch (block.__typename) {
|
switch (block.__typename) {
|
||||||
@@ -26,6 +27,7 @@ export function Blocks({ blocks }: BlocksProps) {
|
|||||||
dynamicContent={block.dynamic_content}
|
dynamicContent={block.dynamic_content}
|
||||||
firstItem={firstItem}
|
firstItem={firstItem}
|
||||||
key={`${block.dynamic_content.title}-${idx}`}
|
key={`${block.dynamic_content.title}-${idx}`}
|
||||||
|
lang={lang}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
||||||
|
|||||||
Reference in New Issue
Block a user