'use client';
import { OrderCard } from './components/order-card';
import { type SlotComponentProps } from './types';
import { useSlotQuery } from '@/hooks/slots';

export function SlotOrdersList({ documentId }: Readonly<SlotComponentProps>) {
  const { data } = useSlotQuery({ documentId });
  const slot = data?.data?.slot;

  if (!slot) return null;

  return (
    <div className="flex flex-col space-y-2">
      <h1 className="font-bold">Записи</h1>
      {slot?.orders.map((order) => order && <OrderCard key={order.documentId} {...order} />)}
    </div>
  );
}
