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:
@@ -3,10 +3,17 @@ import Link from "@/components/TempDesignSystem/Link"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
export default async function CommunicationSlot() {
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function CommunicationSlot({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
|
||||
const { formatMessage } = await getIntl()
|
||||
return (
|
||||
<section className={styles.container}>
|
||||
|
||||
@@ -7,10 +7,14 @@ import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
export default async function CreditCardSlot() {
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function CreditCardSlot({ params }: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
const { formatMessage } = await getIntl()
|
||||
const creditCards = await serverClient().user.creditCards()
|
||||
|
||||
|
||||
@@ -5,10 +5,16 @@ import Link from "@/components/TempDesignSystem/Link"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
export default async function MembershipCardSlot() {
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function MembershipCardSlot({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
const { formatMessage } = await getIntl()
|
||||
const membershipCards = await serverClient().user.membershipCards()
|
||||
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Form from "@/components/Forms/Edit/Profile"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function EditProfileSlot({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
|
||||
export default async function EditProfileSlot() {
|
||||
const user = await serverClient().user.get({ mask: false })
|
||||
if (!user || "error" in user) {
|
||||
return null
|
||||
|
||||
@@ -16,12 +16,14 @@ import Link from "@/components/TempDesignSystem/Link"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
import Title from "@/components/TempDesignSystem/Text/Title"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang, setLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function Profile({ params }: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
const { formatMessage } = await getIntl()
|
||||
const user = await serverClient().user.get()
|
||||
if (!user || "error" in user) {
|
||||
@@ -40,7 +42,7 @@ export default async function Profile({ params }: PageArgs<LangParams>) {
|
||||
</Title>
|
||||
</hgroup>
|
||||
<Button asChild intent="primary" size="small" theme="base">
|
||||
<Link color="none" href={profileEdit[params.lang]}>
|
||||
<Link color="none" href={profileEdit[getLang()]}>
|
||||
{formatMessage({ id: "Edit profile" })}
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
@@ -3,8 +3,12 @@ import "./profileLayout.css"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import TrackingSDK from "@/components/TrackingSDK"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
export default async function ProfilePage() {
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function ProfilePage({ params }: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
const accountPage = await serverClient().contentstack.accountPage.get()
|
||||
|
||||
if (!accountPage) {
|
||||
|
||||
Reference in New Issue
Block a user