diff --git a/apps/web/app/(main)/profile/[telegramId]/page.tsx b/apps/web/app/(main)/profile/[telegramId]/page.tsx index c94b1b4..f098adc 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 { ProfileCard } from '@/components/profile/profile-card'; +import { DataCard, PersonCard } from '@/components/profile'; import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; type Props = { params: Promise<{ telegramId: string }> }; @@ -19,7 +19,10 @@ export default async function ProfilePage(props: Readonly) { return ( - +
+ + +
); } diff --git a/apps/web/app/(main)/profile/page.tsx b/apps/web/app/(main)/profile/page.tsx index 1fbf2a9..b81abb8 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 { ProfileCard } from '@/components/profile/profile-card'; +import { DataCard, PersonCard } from '@/components/profile'; import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query'; export default async function ProfilePage() { @@ -12,7 +12,10 @@ export default async function ProfilePage() { return ( - +
+ + +
); } diff --git a/apps/web/components/profile/card-header.tsx b/apps/web/components/profile/card-header.tsx new file mode 100644 index 0000000..5e8f5d1 --- /dev/null +++ b/apps/web/components/profile/card-header.tsx @@ -0,0 +1,12 @@ +type Props = { + title: string; +}; + +export function ProfileCardHeader({ title }: Readonly) { + return ( +
+

{title}

+
+
+ ); +} diff --git a/apps/web/components/profile/checkbox-with-text.tsx b/apps/web/components/profile/checkbox-field.tsx similarity index 100% rename from apps/web/components/profile/checkbox-with-text.tsx rename to apps/web/components/profile/checkbox-field.tsx diff --git a/apps/web/components/profile/profile-card.tsx b/apps/web/components/profile/data-card.tsx similarity index 57% rename from apps/web/components/profile/profile-card.tsx rename to apps/web/components/profile/data-card.tsx index 0d33969..7b04ee0 100644 --- a/apps/web/components/profile/profile-card.tsx +++ b/apps/web/components/profile/data-card.tsx @@ -1,28 +1,16 @@ 'use client'; +import { ProfileCardHeader } from './card-header'; import { updateRole } from './lib/actions'; +import { type ProfileProps } from './types'; import { getProfile, updateProfile } 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 { CheckboxWithText } from '@/components/profile/checkbox-field'; +import { DataField } from '@/components/profile/text-field'; import { Button } from '@repo/ui/components/ui/button'; import { Card } from '@repo/ui/components/ui/card'; import { useQuery } from '@tanstack/react-query'; import Link from 'next/link'; -type ProfileProps = { - readonly telegramId?: string; -}; - -export function ProfileCard(props: ProfileProps) { - return ( -
- - -
- ); -} - -export function ProfileFields({ telegramId }: ProfileProps) { +export function DataCard({ telegramId }: Readonly) { const { data: customer } = useQuery({ queryFn: () => getProfile({ telegramId }), queryKey: telegramId ? ['profile', 'telegramId', telegramId] : ['profile'], @@ -33,11 +21,11 @@ export function ProfileFields({ telegramId }: ProfileProps) { return (
- {telegramId ? false : } + {telegramId ? false : } {telegramId ? ( false ) : ( - )} - ); } - -function Person({ telegramId }: ProfileProps) { - const { data: customer } = useQuery({ - queryFn: () => getProfile({ telegramId }), - queryKey: telegramId ? ['profile', 'telegramId', telegramId] : ['profile'], - }); - - if (!customer) return null; - - return ( - -
- - - {customer?.name.charAt(0)} - -

{customer?.name}

-
-
- ); -} - -function ProfileFieldsHeader() { - return ( -
-

Ваши данные

-
-
- ); -} diff --git a/apps/web/components/profile/index.ts b/apps/web/components/profile/index.ts new file mode 100644 index 0000000..ddd60a4 --- /dev/null +++ b/apps/web/components/profile/index.ts @@ -0,0 +1,2 @@ +export * from './data-card'; +export * from './person-card'; diff --git a/apps/web/components/profile/person-card.tsx b/apps/web/components/profile/person-card.tsx new file mode 100644 index 0000000..81cbd3c --- /dev/null +++ b/apps/web/components/profile/person-card.tsx @@ -0,0 +1,27 @@ +'use client'; +import { type ProfileProps } from './types'; +import { getProfile } from '@/actions/profile'; +import { Avatar, AvatarFallback, AvatarImage } from '@repo/ui/components/ui/avatar'; +import { Card } from '@repo/ui/components/ui/card'; +import { useQuery } from '@tanstack/react-query'; + +export function PersonCard({ telegramId }: Readonly) { + const { data: customer } = useQuery({ + queryFn: () => getProfile({ telegramId }), + queryKey: telegramId ? ['profile', 'telegramId', telegramId] : ['profile'], + }); + + if (!customer) return null; + + return ( + +
+ + + {customer?.name.charAt(0)} + +

{customer?.name}

+
+
+ ); +} diff --git a/apps/web/components/profile/profile-field.tsx b/apps/web/components/profile/text-field.tsx similarity index 98% rename from apps/web/components/profile/profile-field.tsx rename to apps/web/components/profile/text-field.tsx index 9fd187c..c458223 100644 --- a/apps/web/components/profile/profile-field.tsx +++ b/apps/web/components/profile/text-field.tsx @@ -16,7 +16,7 @@ type ProfileFieldProps = { readonly value: string; }; -export function ProfileField({ +export function DataField({ disabled = false, fieldName, id, diff --git a/apps/web/components/profile/types.tsx b/apps/web/components/profile/types.tsx new file mode 100644 index 0000000..974e69f --- /dev/null +++ b/apps/web/components/profile/types.tsx @@ -0,0 +1,3 @@ +export type ProfileProps = { + readonly telegramId?: string; +};