58 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* eslint-disable canonical/id-match */
'use client';
import { OrderCard } from '@/components/shared/order-card';
import { useCustomerQuery } from '@/hooks/api/customers';
import { useOrdersQuery } from '@/hooks/api/orders';
import { Enum_Customer_Role } from '@repo/graphql/types';
export function ClientsOrdersList() {
const { data: { customer } = {} } = useCustomerQuery();
const isMaster = customer?.role === Enum_Customer_Role.Master;
const { data: { orders } = {}, isLoading } = useOrdersQuery({
filters: {
slot: {
master: {
documentId: {
eq: isMaster ? customer?.documentId : undefined,
},
},
},
},
});
if (!orders?.length || isLoading) return null;
return (
<div className="flex flex-col space-y-2">
<h1 className="font-bold">Записи клиентов</h1>
{orders?.map((order) => order && <OrderCard key={order.documentId} {...order} />)}
</div>
);
}
export function OrdersList() {
const { data: { customer } = {} } = useCustomerQuery();
const { data: { orders } = {}, isLoading } = useOrdersQuery({
filters: {
client: {
documentId: {
eq: customer?.documentId,
},
},
},
});
if (!orders?.length || isLoading) return null;
return (
<div className="flex flex-col space-y-2">
<h1 className="font-bold">Ваши записи</h1>
{orders?.map((order) => order && <OrderCard key={order.documentId} {...order} />)}
</div>
);
}