feat(SW-1543): move auth check within component to be suspended
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
import { SurpriseIcon } from "@/components/Icons"
|
import { SurpriseIcon } from "@/components/Icons"
|
||||||
import Image from "@/components/Image"
|
import Image from "@/components/Image"
|
||||||
import Button from "@/components/TempDesignSystem/Button"
|
import Button from "@/components/TempDesignSystem/Button"
|
||||||
@@ -15,9 +17,14 @@ interface JoinScandicFriendsProps {
|
|||||||
content: JoinScandicFriends
|
content: JoinScandicFriends
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function JoinScandicFriends({
|
export default async function JoinScandicFriends({
|
||||||
content,
|
content,
|
||||||
}: JoinScandicFriendsProps) {
|
}: JoinScandicFriendsProps) {
|
||||||
|
const session = await getProfileSafely()
|
||||||
|
if (session) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const { show_header, show_usp, usp, primary_button } = content
|
const { show_header, show_usp, usp, primary_button } = content
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Suspense } from "react"
|
||||||
|
|
||||||
import CardsGrid from "@/components/Blocks/CardsGrid"
|
import CardsGrid from "@/components/Blocks/CardsGrid"
|
||||||
import CarouselCards from "@/components/Blocks/CarouselCards"
|
import CarouselCards from "@/components/Blocks/CarouselCards"
|
||||||
import DynamicContent from "@/components/Blocks/DynamicContent"
|
import DynamicContent from "@/components/Blocks/DynamicContent"
|
||||||
@@ -106,7 +108,11 @@ export default function Blocks({ blocks }: BlocksProps) {
|
|||||||
case BlocksEnums.block.FullWidthCampaign:
|
case BlocksEnums.block.FullWidthCampaign:
|
||||||
return <FullWidthCampaign content={block.full_width_campaign} />
|
return <FullWidthCampaign content={block.full_width_campaign} />
|
||||||
case BlocksEnums.block.JoinScandicFriends:
|
case BlocksEnums.block.JoinScandicFriends:
|
||||||
return <JoinScandicFriends content={block.join_scandic_friends} />
|
return (
|
||||||
|
<Suspense>
|
||||||
|
<JoinScandicFriends content={block.join_scandic_friends} />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section:empty {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.section {
|
.section {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import {
|
|||||||
TrackingChannelEnum,
|
TrackingChannelEnum,
|
||||||
type TrackingSDKPageData,
|
type TrackingSDKPageData,
|
||||||
} from "@/types/components/tracking"
|
} from "@/types/components/tracking"
|
||||||
import { BlocksEnums } from "@/types/enums/blocks"
|
|
||||||
import type {
|
import type {
|
||||||
GetStartPageData,
|
GetStartPageData,
|
||||||
GetStartPageRefsSchema,
|
GetStartPageRefsSchema,
|
||||||
@@ -184,21 +183,8 @@ export const startPageQueryRouter = router({
|
|||||||
siteVersion: "new-web",
|
siteVersion: "new-web",
|
||||||
}
|
}
|
||||||
|
|
||||||
const session = await ctx.auth()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startPage: {
|
startPage: startPage.data.start_page,
|
||||||
...startPage.data.start_page,
|
|
||||||
blocks: startPage.data.start_page.blocks.filter((block) => {
|
|
||||||
if (
|
|
||||||
block.typename === BlocksEnums.block.JoinScandicFriends &&
|
|
||||||
session
|
|
||||||
) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return block
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
tracking,
|
tracking,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user