chore: move user fetch

This commit is contained in:
Arvid Norlin
2024-06-10 12:53:26 +02:00
parent 85aab88aec
commit 99c1822021
3 changed files with 6 additions and 13 deletions

View File

@@ -16,7 +16,9 @@ import type {
} from "@/types/components/loyalty/blocks"
import { LoyaltyComponentEnum } from "@/types/components/loyalty/enums"
function DynamicComponentBlock({ component, user }: DynamicComponentProps) {
async function DynamicComponentBlock({ component }: DynamicComponentProps) {
const user = await serverClient().user.get()
switch (component) {
case LoyaltyComponentEnum.how_it_works:
return <HowItWorks />
@@ -29,7 +31,7 @@ function DynamicComponentBlock({ component, user }: DynamicComponentProps) {
}
}
export default async function DynamicContent({
export default function DynamicContent({
dynamicContent,
}: DynamicContentProps) {
const displayHeader = !!(
@@ -37,7 +39,6 @@ export default async function DynamicContent({
dynamicContent.subtitle ||
dynamicContent.title
)
const user = await serverClient().user.get()
return (
<section className={styles.container}>
@@ -56,14 +57,7 @@ export default async function DynamicContent({
</Subtitle>
</header>
) : null}
{dynamicContent.component === LoyaltyComponentEnum.overview_table ? (
<DynamicComponentBlock
component={dynamicContent.component}
user={user}
/>
) : (
<DynamicComponentBlock component={dynamicContent.component} />
)}
<DynamicComponentBlock component={dynamicContent.component} />
</section>
)
}

View File

@@ -7,7 +7,7 @@ import CardsGrid from "./CardsGrid"
import type { BlocksProps } from "@/types/components/loyalty/blocks"
import { LoyaltyBlocksTypenameEnum } from "@/types/components/loyalty/enums"
export async function Blocks({ blocks }: BlocksProps) {
export function Blocks({ blocks }: BlocksProps) {
return blocks.map((block) => {
switch (block.__typename) {
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent: