Merged in feature/refactor-lang (pull request #387)
feat: SW-238 Avoid prop drilling of lang Approved-by: Michael Zetterberg
This commit is contained in:
@@ -8,6 +8,7 @@ import { membershipLevels } from "@/constants/membershipLevels"
|
||||
|
||||
import Image from "@/components/Image"
|
||||
import Select from "@/components/TempDesignSystem/Select"
|
||||
import useLang from "@/hooks/useLang"
|
||||
import { getMembership } from "@/utils/user"
|
||||
|
||||
import DA from "./data/DA.json"
|
||||
@@ -33,7 +34,6 @@ import {
|
||||
OverviewTableProps,
|
||||
OverviewTableReducerAction,
|
||||
} from "@/types/components/loyalty/blocks"
|
||||
import { LangParams } from "@/types/params"
|
||||
import type { User } from "@/types/user"
|
||||
|
||||
const levelsTranslations = {
|
||||
@@ -127,9 +127,9 @@ function reducer(state: any, action: OverviewTableReducerAction) {
|
||||
|
||||
export default function OverviewTable({
|
||||
activeMembership,
|
||||
lang,
|
||||
}: OverviewTableProps & LangParams) {
|
||||
}: OverviewTableProps) {
|
||||
const intl = useIntl()
|
||||
const lang = useLang()
|
||||
const levelsData = levelsTranslations[lang]
|
||||
const [selectionState, dispatch] = useReducer(
|
||||
reducer,
|
||||
|
||||
@@ -17,12 +17,8 @@ import type {
|
||||
DynamicContentProps,
|
||||
} from "@/types/components/loyalty/blocks"
|
||||
import { LoyaltyComponentEnum } from "@/types/components/loyalty/enums"
|
||||
import { LangParams } from "@/types/params"
|
||||
|
||||
async function DynamicComponentBlock({
|
||||
component,
|
||||
lang,
|
||||
}: DynamicComponentProps & LangParams) {
|
||||
async function DynamicComponentBlock({ component }: DynamicComponentProps) {
|
||||
const membershipLevel = await serverClient().user.membershipLevel()
|
||||
switch (component) {
|
||||
case LoyaltyComponentEnum.how_it_works:
|
||||
@@ -30,7 +26,7 @@ async function DynamicComponentBlock({
|
||||
case LoyaltyComponentEnum.loyalty_levels:
|
||||
return <LoyaltyLevels />
|
||||
case LoyaltyComponentEnum.overview_table:
|
||||
return <OverviewTable activeMembership={membershipLevel} lang={lang} />
|
||||
return <OverviewTable activeMembership={membershipLevel} />
|
||||
default:
|
||||
return null
|
||||
}
|
||||
@@ -39,8 +35,7 @@ async function DynamicComponentBlock({
|
||||
export default function DynamicContent({
|
||||
dynamicContent,
|
||||
firstItem,
|
||||
lang,
|
||||
}: DynamicContentProps & LangParams) {
|
||||
}: DynamicContentProps) {
|
||||
const displayHeader = !!(
|
||||
dynamicContent.link ||
|
||||
dynamicContent.subtitle ||
|
||||
@@ -63,7 +58,7 @@ export default function DynamicContent({
|
||||
topTitle={firstItem}
|
||||
/>
|
||||
) : null}
|
||||
<DynamicComponentBlock component={dynamicContent.component} lang={lang} />
|
||||
<DynamicComponentBlock component={dynamicContent.component} />
|
||||
{displayHeader && (
|
||||
<SectionLink link={dynamicContent.link} variant="mobile" />
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user