import React from 'react';
import Modal from '../ui/Modal';
import ResourceServicesPanel, { type ServiceOfferingLine } from './ResourceServicesPanel';
import type { ClinicResource, ResourceServiceOffering, ServiceItemOption } from '../../types';

interface Props {
  resource: ClinicResource | null;
  offerings: ResourceServiceOffering[];
  services: ServiceItemOption[];
  saving: boolean;
  onClose: () => void;
  onSave: (lines: ServiceOfferingLine[]) => void;
}

/** همان پنل سرویس‌ها، در قاب مودالِ فهرست منابع. */
export default function ResourceServicesModal({
  resource, offerings, services, saving, onClose, onSave,
}: Props) {
  return (
    <Modal open={resource !== null} onClose={onClose} title={`سرویس‌های ${resource?.name ?? 'منبع'}`}>
      <ResourceServicesPanel
        resource={resource}
        offerings={offerings}
        services={services}
        saving={saving}
        onCancel={onClose}
        onSave={onSave}
      />
    </Modal>
  );
}
