From 1b1963e5d94bc1285e37871bd081131596cf96b7 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 10 Jun 2025 13:25:45 +0300 Subject: [PATCH] prefetchQuery customer profile pages --- apps/web/app/(main)/profile/[telegramId]/page.tsx | 6 ++++++ apps/web/app/(main)/profile/page.tsx | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/apps/web/app/(main)/profile/[telegramId]/page.tsx b/apps/web/app/(main)/profile/[telegramId]/page.tsx index 8f1e663..c9095f8 100644 --- a/apps/web/app/(main)/profile/[telegramId]/page.tsx +++ b/apps/web/app/(main)/profile/[telegramId]/page.tsx @@ -1,3 +1,4 @@ +import { getCustomer } from '@/actions/api/customers'; import { Container } from '@/components/layout'; import { PageHeader } from '@/components/navigation'; import { ContactDataCard, PersonCard } from '@/components/profile'; @@ -11,6 +12,11 @@ export default async function ProfilePage(props: Readonly) { const queryClient = new QueryClient(); + await queryClient.prefetchQuery({ + queryFn: () => getCustomer({ telegramId }), + queryKey: ['customer', telegramId], + }); + return ( diff --git a/apps/web/app/(main)/profile/page.tsx b/apps/web/app/(main)/profile/page.tsx index 372caa5..83d9f02 100644 --- a/apps/web/app/(main)/profile/page.tsx +++ b/apps/web/app/(main)/profile/page.tsx @@ -1,3 +1,5 @@ +import { getCustomer } from '@/actions/api/customers'; +import { getSessionUser } from '@/actions/session'; import { Container } from '@/components/layout'; import { LinksCard, PersonCard, ProfileDataCard } from '@/components/profile'; import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; @@ -5,6 +7,13 @@ import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query export default async function ProfilePage() { const queryClient = new QueryClient(); + const { telegramId } = await getSessionUser(); + + await queryClient.prefetchQuery({ + queryFn: () => getCustomer({ telegramId }), + queryKey: ['customer', telegramId], + }); + return (