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:
parent
04739612ca
commit
7af67b1910
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user