'use client'; import { CardSectionHeader } from '@/components/ui'; import { ContactsContextProvider } from '@/context/contacts'; import { useCustomerContacts } from '@/hooks/api/contacts'; // 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 { Card } from '@repo/ui/components/ui/card'; import { Label } from '@repo/ui/components/ui/label'; import { LoadingSpinner } from '@repo/ui/components/ui/spinner'; import { cn } from '@repo/ui/lib/utils'; import Image from 'next/image'; import { useEffect } from 'react'; type ContactsGridProps = { readonly contacts: CustomerFieldsFragment[]; readonly onSelect: (contactId: null | string) => void; readonly selected?: null | string; readonly title: string; }; export function ContactsGridBase({ contacts, onSelect, selected, title }: ContactsGridProps) { return (
{contacts.map((contact) => { if (!contact) return null; const isCurrentUser = contact?.name === 'Я'; return ( ); })}
); } export const MastersGrid = withContext(ContactsContextProvider)(function () { const { contacts, isLoading, setFilter } = useCustomerContacts(); const masterId = useOrderStore((store) => store.masterId); const setMasterId = useOrderStore((store) => store.setMasterId); useEffect(() => { setFilter('masters'); }, [setFilter]); if (isLoading) return ; return ( setMasterId(contactId)} selected={masterId} title="Мастера" /> ); }); export const ClientsGrid = withContext(ContactsContextProvider)(function () { const { contacts, isLoading, setFilter } = useCustomerContacts(); const clientId = useOrderStore((store) => store.clientId); const setClientId = useOrderStore((store) => store.setClientId); useEffect(() => { setFilter('clients'); }, [setFilter]); if (isLoading) return ; return ( setClientId(contactId)} selected={clientId} title="Клиенты" /> ); });