From df076f50f59750af631db476b7b0b17e646037a8 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Thu, 22 Aug 2024 09:01:04 +0200 Subject: [PATCH] fix: hide my pages menu for logged in users --- .../Loyalty/Sidebar/MyPagesNavigation/index.tsx | 13 +++++++++++++ components/Loyalty/Sidebar/index.tsx | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 components/Loyalty/Sidebar/MyPagesNavigation/index.tsx diff --git a/components/Loyalty/Sidebar/MyPagesNavigation/index.tsx b/components/Loyalty/Sidebar/MyPagesNavigation/index.tsx new file mode 100644 index 000000000..19ea70405 --- /dev/null +++ b/components/Loyalty/Sidebar/MyPagesNavigation/index.tsx @@ -0,0 +1,13 @@ +import { serverClient } from "@/lib/trpc/server" + +import MyPagesSidebar from "@/components/MyPages/Sidebar" + +export async function MyPagesNavigation() { + const user = await serverClient().user.name() + + // Check if we have user, that means we are logged in andt the My Pages menu can show. + if (!user) { + return null + } + return +} diff --git a/components/Loyalty/Sidebar/index.tsx b/components/Loyalty/Sidebar/index.tsx index 912d86e27..53f0137b8 100644 --- a/components/Loyalty/Sidebar/index.tsx +++ b/components/Loyalty/Sidebar/index.tsx @@ -1,7 +1,7 @@ import JsonToHtml from "@/components/JsonToHtml" -import SidebarMyPages from "@/components/MyPages/Sidebar" import JoinLoyaltyContact from "./JoinLoyalty" +import { MyPagesNavigation } from "./MyPagesNavigation" import styles from "./sidebar.module.css" @@ -38,7 +38,7 @@ export default function SidebarLoyalty({ blocks }: SidebarProps) { case SidebarTypenameEnum.LoyaltyPageSidebarDynamicContent: switch (block.dynamic_content.component) { case LoyaltySidebarDynamicComponentEnum.my_pages_navigation: - return + return default: return null }