'use client';

import { ServiceCard } from '../shared/service-card';
import { type OrderComponentProps } from './types';
import { useOrderQuery } from '@/hooks/api/orders';

export function OrderServices({ documentId }: Readonly<OrderComponentProps>) {
  const { data: { order } = {} } = useOrderQuery({ documentId });

  if (!order) return null;

  return (
    <div className="flex flex-col space-y-2">
      <h1 className="font-bold">Услуги</h1>
      {order.services?.map(
        (service) => service && <ServiceCard key={service.documentId} {...service} />,
      )}
    </div>
  );
}
