From 99c1822021281d4d87ddb7dc7152607b1b81e777 Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Mon, 10 Jun 2024 12:53:26 +0200 Subject: [PATCH] chore: move user fetch --- .../Loyalty/Blocks/DynamicContent/index.tsx | 16 +++++----------- components/Loyalty/Blocks/index.tsx | 2 +- types/components/loyalty/blocks.ts | 1 - 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/components/Loyalty/Blocks/DynamicContent/index.tsx b/components/Loyalty/Blocks/DynamicContent/index.tsx index 0db82a75b..1fc74d547 100644 --- a/components/Loyalty/Blocks/DynamicContent/index.tsx +++ b/components/Loyalty/Blocks/DynamicContent/index.tsx @@ -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 @@ -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 (
@@ -56,14 +57,7 @@ export default async function DynamicContent({ ) : null} - {dynamicContent.component === LoyaltyComponentEnum.overview_table ? ( - - ) : ( - - )} +
) } diff --git a/components/Loyalty/Blocks/index.tsx b/components/Loyalty/Blocks/index.tsx index a47970ad8..5901f79d1 100644 --- a/components/Loyalty/Blocks/index.tsx +++ b/components/Loyalty/Blocks/index.tsx @@ -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: diff --git a/types/components/loyalty/blocks.ts b/types/components/loyalty/blocks.ts index 80dc2c42c..8e500d11c 100644 --- a/types/components/loyalty/blocks.ts +++ b/types/components/loyalty/blocks.ts @@ -21,7 +21,6 @@ export type DynamicContentProps = { export type DynamicComponentProps = { component: DynamicContent["dynamic_content"]["component"] - user?: User } export type CardsGridProps = Pick