'use client'; import { DataNotFound } from '../shared/alert'; import { OrderCard } from '../shared/order-card'; import { type ProfileProps } from './types'; import { useCustomerQuery } from '@/hooks/api/customers'; import { useOrdersInfiniteQuery } from '@/hooks/api/orders'; import { Button } from '@repo/ui/components/ui/button'; import { LoadingSpinner } from '@repo/ui/components/ui/spinner'; export function ProfileOrdersList({ telegramId }: Readonly) { const { data: { customer } = {} } = useCustomerQuery(); const { data: { customer: profile } = {} } = useCustomerQuery({ telegramId }); const { data: { pages } = {}, fetchNextPage, hasNextPage, isLoading, } = useOrdersInfiniteQuery( { filters: { // Показываем все записи между текущим пользователем и профилем or: [ { client: { documentId: { eq: customer?.documentId } }, slot: { master: { documentId: { eq: profile?.documentId } } }, }, { client: { documentId: { eq: profile?.documentId } }, slot: { master: { documentId: { eq: customer?.documentId } } }, }, ], }, }, { enabled: Boolean(profile?.documentId) && Boolean(customer?.documentId) }, ); const orders = pages?.flatMap((page) => page.orders) ?? []; return (

Недавние записи

{isLoading && } {!isLoading && !orders.length ? : null} {orders?.map((order) => order && )} {hasNextPage && ( )}
); }