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.
This commit is contained in:
vchikalkin 2025-09-04 14:52:45 +03:00
parent 384119672f
commit 0cdded078a

View File

@ -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 (
<HydrationBoundary state={dehydrate(queryClient)}>
<Container className="px-0">
<PersonCard />
<SubscriptionInfoBar />
{isMaster ? <SubscriptionInfoBar /> : null}
<ProfileDataCard />
<LinksCard />
</Container>