From c9a4c23564f125c9446a9b65573289bccbeb03d1 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 8 Sep 2025 14:36:12 +0300 Subject: [PATCH] refactor(contacts): update grid components and improve customer role handling - Renamed InvitedByGrid to MastersGrid and InvitedGrid to ClientsGrid for clarity. - Enhanced customer role checks by using documentId for identifying the current user. - Updated the contacts passed to grid components to reflect the new naming and role structure. - Adjusted titles in grid components for better user experience. --- .../orders/order-form/contacts-grid.tsx | 25 +++++++++++++------ .../components/orders/order-form/index.tsx | 6 ++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/apps/web/components/orders/order-form/contacts-grid.tsx b/apps/web/components/orders/order-form/contacts-grid.tsx index d996ee2..90c627b 100644 --- a/apps/web/components/orders/order-form/contacts-grid.tsx +++ b/apps/web/components/orders/order-form/contacts-grid.tsx @@ -1,13 +1,15 @@ +/* eslint-disable canonical/id-match */ 'use client'; import { CardSectionHeader } from '@/components/ui'; import { ContactsContextProvider } from '@/context/contacts'; import { useCustomerContacts } from '@/hooks/api/contacts'; +import { useCustomerQuery } from '@/hooks/api/customers'; // eslint-disable-next-line import/extensions import AvatarPlaceholder from '@/public/avatar/avatar_placeholder.png'; import { useOrderStore } from '@/stores/order'; import { withContext } from '@/utils/context'; -import { type CustomerFieldsFragment } from '@repo/graphql/types'; +import { type CustomerFieldsFragment, Enum_Customer_Role } from '@repo/graphql/types'; import { Card } from '@repo/ui/components/ui/card'; import { Label } from '@repo/ui/components/ui/label'; import { LoadingSpinner } from '@repo/ui/components/ui/spinner'; @@ -23,6 +25,8 @@ type ContactsGridProps = { }; export function ContactsGridBase({ contacts, onSelect, selected, title }: ContactsGridProps) { + const { data: { customer } = {} } = useCustomerQuery(); + return (
@@ -31,7 +35,7 @@ export function ContactsGridBase({ contacts, onSelect, selected, title }: Contac {contacts.map((contact) => { if (!contact) return null; - const isCurrentUser = contact?.name === 'Я'; + const isCurrentUser = contact?.documentId === customer?.documentId; return (