fix: move user fetch

This commit is contained in:
Arvid Norlin
2024-04-25 14:35:48 +02:00
parent 840a20c4c1
commit 2ddcbff009
6 changed files with 12 additions and 14 deletions

View File

@@ -7,7 +7,6 @@ import styles from "./page.module.css"
import type { LangParams, PageArgs } from "@/types/params"
export default async function BenefitsPage({ params }: PageArgs<LangParams>) {
const user = await serverClient().user.get()
const accountPage = await serverClient().contentstack.accountPage.getBenefits(
{
lang: params.lang,
@@ -16,7 +15,7 @@ export default async function BenefitsPage({ params }: PageArgs<LangParams>) {
return (
<main className={styles.container}>
<Content user={user} lang={params.lang} content={accountPage.content} />
<Content lang={params.lang} content={accountPage.content} />
</main>
)
}

View File

@@ -1,15 +1,14 @@
import { _ } from "@/lib/translation"
import { serverClient } from "@/lib/trpc/server"
import Content from "@/components/MyPages/AccountPage/Content"
import MaxWidth from "@/components/MaxWidth"
import Content from "@/components/MyPages/AccountPage/Content"
import styles from "./page.module.css"
import type { LangParams, PageArgs } from "@/types/params"
export default async function MyPageOverview({ params }: PageArgs<LangParams>) {
const user = await serverClient().user.get()
const accountPage = await serverClient().contentstack.accountPage.getOverview(
{
lang: params.lang,
@@ -18,7 +17,7 @@ export default async function MyPageOverview({ params }: PageArgs<LangParams>) {
return (
<MaxWidth className={styles.blocks} tag="main">
<Content user={user} lang={params.lang} content={accountPage.content} />
<Content lang={params.lang} content={accountPage.content} />
</MaxWidth>
)
}

View File

@@ -18,10 +18,10 @@ import {
DynamicContentComponents,
} from "@/types/requests/myPages/accountpage"
function DynamicComponent({ user, component, props }: AccountPageContentProps) {
function DynamicComponent({ component, props }: AccountPageContentProps) {
switch (component) {
case DynamicContentComponents.membership_overview:
return <Overview user={user} title={props.title} />
return <Overview title={props.title} />
case DynamicContentComponents.previous_stays:
return <PreviousStays {...props} />
case DynamicContentComponents.soonest_stays:
@@ -37,7 +37,7 @@ function DynamicComponent({ user, component, props }: AccountPageContentProps) {
}
}
export default function Content({ user, lang, content }: ContentProps) {
export default function Content({ lang, content }: ContentProps) {
return (
<>
{content.map((item) => {
@@ -61,7 +61,6 @@ export default function Content({ user, lang, content }: ContentProps) {
return (
<DynamicComponent
component={item.dynamic_content.component}
user={user}
props={componentProps}
/>
)

View File

@@ -1,3 +1,5 @@
import { serverClient } from "@/lib/trpc/server"
import Title from "@/components/Title"
import Friend from "./Friend"
@@ -7,7 +9,9 @@ import styles from "./overview.module.css"
import type { OverviewProps } from "@/types/components/myPages/myPage/overview"
export default function Overview({ user, title }: OverviewProps) {
export default async function Overview({ title }: OverviewProps) {
const user = await serverClient().user.get()
return (
<section className={styles.container}>
<header>

View File

@@ -1,9 +1,9 @@
import { Lang } from "@/constants/languages"
import {
AccountPageContentItem,
DynamicContentComponents,
} from "@/types/requests/myPages/accountpage"
import { User } from "@/types/user"
export type AccountPageContentProps = {
component: DynamicContentComponents
@@ -13,7 +13,6 @@ export type AccountPageContentProps = {
link?: { href: string; text: string }
lang: Lang
}
user: User
}
export type AccountPageComponentProps = {
@@ -24,7 +23,6 @@ export type AccountPageComponentProps = {
}
export type ContentProps = {
user: User
lang: Lang
content: AccountPageContentItem[]
}

View File

@@ -2,5 +2,4 @@ import type { User } from "@/types/user"
export type OverviewProps = {
title?: string
user: User
}