From 12e5f3654ddd1fe06cd131081738e3ec1736af7b Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 29 Jan 2025 17:20:49 +0300 Subject: [PATCH] split DataCard to 2 components --- .../app/(main)/profile/[telegramId]/page.tsx | 4 +- apps/web/app/(main)/profile/page.tsx | 4 +- .../components/profile/cards/data-card.tsx | 85 +++++++++---------- 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/apps/web/app/(main)/profile/[telegramId]/page.tsx b/apps/web/app/(main)/profile/[telegramId]/page.tsx index f098adc..bf7c56e 100644 --- a/apps/web/app/(main)/profile/[telegramId]/page.tsx +++ b/apps/web/app/(main)/profile/[telegramId]/page.tsx @@ -1,6 +1,6 @@ import { getProfile } from '@/actions/profile'; import { PageHeader } from '@/components/navigation'; -import { DataCard, PersonCard } from '@/components/profile'; +import { ContactDataCard, PersonCard } from '@/components/profile'; import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; type Props = { params: Promise<{ telegramId: string }> }; @@ -21,7 +21,7 @@ export default async function ProfilePage(props: Readonly) {
- +
); diff --git a/apps/web/app/(main)/profile/page.tsx b/apps/web/app/(main)/profile/page.tsx index b81abb8..47f847a 100644 --- a/apps/web/app/(main)/profile/page.tsx +++ b/apps/web/app/(main)/profile/page.tsx @@ -1,5 +1,5 @@ import { getProfile } from '@/actions/profile'; -import { DataCard, PersonCard } from '@/components/profile'; +import { PersonCard, ProfileDataCard } from '@/components/profile'; import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; export default async function ProfilePage() { @@ -14,7 +14,7 @@ export default async function ProfilePage() {
- +
); diff --git a/apps/web/components/profile/cards/data-card.tsx b/apps/web/components/profile/cards/data-card.tsx index a2c05e4..a1d17b1 100644 --- a/apps/web/components/profile/cards/data-card.tsx +++ b/apps/web/components/profile/cards/data-card.tsx @@ -10,10 +10,10 @@ import { Card } from '@repo/ui/components/ui/card'; import { useQuery } from '@tanstack/react-query'; import Link from 'next/link'; -export function DataCard({ telegramId }: Readonly) { +export function ContactDataCard({ telegramId }: Readonly) { const { data: customer } = useQuery({ queryFn: () => getProfile({ telegramId }), - queryKey: telegramId ? ['profile', 'telegramId', telegramId] : ['profile'], + queryKey: ['profile', 'telegramId', telegramId], }); if (!customer) return null; @@ -21,50 +21,45 @@ export function DataCard({ telegramId }: Readonly) { return (
- {telegramId ? false : } - {telegramId ? ( - false - ) : ( - - )} - - + + - {telegramId ? ( - false - ) : ( - - )} - {telegramId ? ( - - ) : ( - false - )} + +
+
+ ); +} + +export function ProfileDataCard() { + const { data: customer } = useQuery({ + queryFn: () => getProfile(), + queryKey: ['profile'], + }); + + if (!customer) return null; + + return ( + +
+ + + +
);