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:
Niclas Edenvin
2024-08-14 11:00:20 +00:00
parent 35128dbf44
commit e67212bd94
94 changed files with 378 additions and 322 deletions

View File

@@ -8,12 +8,11 @@ import MaxWidth from "@/components/MaxWidth"
import Content from "@/components/MyPages/AccountPage/Webview/Content"
import TrackingSDK from "@/components/TrackingSDK"
import LinkToOverview from "@/components/Webviews/LinkToOverview"
import { getLang } from "@/i18n/serverContext"
import styles from "./accountPage.module.css"
import { LangParams } from "@/types/params"
export default async function MyPages({ lang }: LangParams) {
export default async function MyPages() {
const accountPageRes = await serverClient().contentstack.accountPage.get()
if (!accountPageRes) {
@@ -22,13 +21,14 @@ export default async function MyPages({ lang }: LangParams) {
const { tracking, accountPage } = accountPageRes
const linkToOverview = `/${lang}/webview${accountPage.url}` !== overview[lang]
const linkToOverview =
`/${getLang()}/webview${accountPage.url}` !== overview[getLang()]
return (
<>
<MaxWidth className={styles.blocks} tag="main">
{linkToOverview ? <LinkToOverview lang={lang} /> : null}
<Content lang={lang} content={accountPage.content} />
{linkToOverview ? <LinkToOverview /> : null}
<Content content={accountPage.content} />
</MaxWidth>
<TrackingSDK pageData={tracking} />

View File

@@ -8,9 +8,7 @@ import LinkToOverview from "@/components/Webviews/LinkToOverview"
import styles from "./loyaltyPage.module.css"
import { LangParams } from "@/types/params"
export default async function AboutScandicFriends({ lang }: LangParams) {
export default async function AboutScandicFriends() {
const loyaltyPageRes = await serverClient().contentstack.loyaltyPage.get()
if (!loyaltyPageRes) {
@@ -21,10 +19,10 @@ export default async function AboutScandicFriends({ lang }: LangParams) {
return (
<>
<section className={styles.content}>
<LinkToOverview lang={lang} />
<LinkToOverview />
<MaxWidth tag="main" className={styles.blocks}>
<Title>{loyaltyPage.heading}</Title>
<Blocks blocks={loyaltyPage.blocks} lang={lang} />
<Blocks blocks={loyaltyPage.blocks} />
</MaxWidth>
</section>