diff --git a/apps/web/app/(main)/profile/page.tsx b/apps/web/app/(main)/profile/page.tsx index 8d4e3ea..da4aee5 100644 --- a/apps/web/app/(main)/profile/page.tsx +++ b/apps/web/app/(main)/profile/page.tsx @@ -1,40 +1,18 @@ -import { getProfile, updateProfile, updateRole } from '@/actions/profile'; -import { CheckboxWithText } from '@/components/profile/checkbox-with-text'; -import { ProfileField } from '@/components/profile/profile-field'; -import { Avatar, AvatarFallback, AvatarImage } from '@repo/ui/components/ui/avatar'; -import { Card, CardContent, CardHeader } from '@repo/ui/components/ui/card'; +import { getProfile } from '@/actions/profile'; +import { ProfileCard } from '@/components/profile/profile-card'; +import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; export default async function ProfilePage() { - const customer = await getProfile(); - const photoUrl = customer?.photoUrl ?? 'https://github.com/shadcn.png'; + const queryClient = new QueryClient(); - if (!customer) return 'Пользователь не найден. Зарегистрируйтесь с помощью бота.'; + await queryClient.prefetchQuery({ + queryFn: getProfile, + queryKey: ['profile'], + }); return ( - - - - - {customer?.name.charAt(0)} - -

{customer?.name}

-
- - - - - -
+ + + ); } diff --git a/apps/web/components/profile/profile-card.tsx b/apps/web/components/profile/profile-card.tsx new file mode 100644 index 0000000..2b42fbf --- /dev/null +++ b/apps/web/components/profile/profile-card.tsx @@ -0,0 +1,44 @@ +'use client'; +import { getProfile, updateProfile, updateRole } from '@/actions/profile'; +import { CheckboxWithText } from '@/components/profile/checkbox-with-text'; +import { ProfileField } from '@/components/profile/profile-field'; +import { Avatar, AvatarFallback, AvatarImage } from '@repo/ui/components/ui/avatar'; +import { Card, CardContent, CardHeader } from '@repo/ui/components/ui/card'; +import { useQuery } from '@tanstack/react-query'; + +export function ProfileCard() { + const { data: customer } = useQuery({ + queryFn: getProfile, + queryKey: ['profile'], + }); + + if (!customer) return
Пользователь не найден. Зарегистрируйтесь с помощью бота.
; + + return ( + + + + + {customer?.name.charAt(0)} + +

{customer?.name}

+
+ + + + + +
+ ); +}