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:
@@ -1,15 +1,15 @@
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
import DynamicContentBlock from "@/components/Loyalty/Blocks/DynamicContent"
|
||||
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
import { modWebviewLink } from "@/utils/webviews"
|
||||
|
||||
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({ lang, blocks }: BlocksProps & LangParams) {
|
||||
export function Blocks({ blocks }: BlocksProps) {
|
||||
return blocks.map((block, idx) => {
|
||||
const firstItem = idx === 0
|
||||
switch (block.__typename) {
|
||||
@@ -35,7 +35,10 @@ export function Blocks({ lang, blocks }: BlocksProps & LangParams) {
|
||||
link: block.dynamic_content.link
|
||||
? {
|
||||
...block.dynamic_content.link,
|
||||
href: modWebviewLink(block.dynamic_content.link.href, lang),
|
||||
href: modWebviewLink(
|
||||
block.dynamic_content.link.href,
|
||||
getLang()
|
||||
),
|
||||
}
|
||||
: undefined,
|
||||
}
|
||||
@@ -45,13 +48,12 @@ export function Blocks({ lang, blocks }: BlocksProps & LangParams) {
|
||||
dynamicContent={dynamicContent}
|
||||
firstItem={firstItem}
|
||||
key={`${block.dynamic_content.title}-${idx}`}
|
||||
lang={lang}
|
||||
/>
|
||||
)
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
||||
const shortcuts = block.shortcuts.shortcuts.map((shortcut) => ({
|
||||
...shortcut,
|
||||
url: modWebviewLink(shortcut.url, lang),
|
||||
url: modWebviewLink(shortcut.url, getLang()),
|
||||
}))
|
||||
return (
|
||||
<Shortcuts
|
||||
|
||||
Reference in New Issue
Block a user