From 7af67b1910e212b9b71c73205520dd874427d169 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 4 Sep 2025 14:52:45 +0300 Subject: [PATCH] feat(profile): conditionally render SubscriptionInfoBar based on user role - Updated ProfilePage to check if the user is a master and conditionally render the SubscriptionInfoBar component. - Refactored customer fetching logic to include a utility function for determining user role. --- apps/web/app/(main)/profile/page.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/app/(main)/profile/page.tsx b/apps/web/app/(main)/profile/page.tsx index a03039b..b198f1a 100644 --- a/apps/web/app/(main)/profile/page.tsx +++ b/apps/web/app/(main)/profile/page.tsx @@ -2,22 +2,25 @@ import { getCustomer } from '@/actions/api/customers'; import { getSessionUser } from '@/actions/session'; import { Container } from '@/components/layout'; import { LinksCard, PersonCard, ProfileDataCard, SubscriptionInfoBar } from '@/components/profile'; +import { isCustomerMaster } from '@repo/utils/customer'; import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; export default async function ProfilePage() { const queryClient = new QueryClient(); const { telegramId } = await getSessionUser(); - await queryClient.prefetchQuery({ + const { customer } = await queryClient.fetchQuery({ queryFn: () => getCustomer({ telegramId }), queryKey: ['customer', telegramId], }); + const isMaster = customer && isCustomerMaster(customer); + return ( - + {isMaster ? : null}