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

@@ -1,5 +1,7 @@
import { serverClient } from "@/lib/trpc/server"
import { getLang } from "@/i18n/serverContext"
import AmenitiesList from "./AmenitiesList"
import IntroSection from "./IntroSection"
import { Rooms } from "./Rooms"
@@ -7,9 +9,7 @@ import TabNavigation from "./TabNavigation"
import styles from "./hotelPage.module.css"
import type { LangParams } from "@/types/params"
export default async function HotelPage({ lang }: LangParams) {
export default async function HotelPage() {
const hotelPageIdentifierData =
await serverClient().contentstack.hotelPage.get()
@@ -19,7 +19,7 @@ export default async function HotelPage({ lang }: LangParams) {
const { attributes, roomCategories } = await serverClient().hotel.getHotel({
hotelId: hotelPageIdentifierData.hotel_page_id,
language: lang,
language: getLang(),
include: ["RoomCategories"],
})

View File

@@ -8,9 +8,7 @@ import TrackingSDK from "@/components/TrackingSDK"
import styles from "./loyaltyPage.module.css"
import type { LangParams } from "@/types/params"
export default async function LoyaltyPage({ lang }: LangParams) {
export default async function LoyaltyPage() {
const loyaltyPageRes = await serverClient().contentstack.loyaltyPage.get()
if (!loyaltyPageRes) {
@@ -23,14 +21,12 @@ export default async function LoyaltyPage({ lang }: LangParams) {
<>
<section className={styles.content}>
{loyaltyPage.sidebar.length ? (
<Sidebar blocks={loyaltyPage.sidebar} lang={lang} />
<Sidebar blocks={loyaltyPage.sidebar} />
) : null}
<MaxWidth className={styles.blocks} tag="main">
<Title>{loyaltyPage.heading}</Title>
{loyaltyPage.blocks ? (
<Blocks blocks={loyaltyPage.blocks} lang={lang} />
) : null}
{loyaltyPage.blocks ? <Blocks blocks={loyaltyPage.blocks} /> : null}
</MaxWidth>
</section>

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>