import { useMemo, useState } from 'react'; import { TextControl } from "../../../components/ui/text-control"; import { Modal } from '../../../components/ui/wp-modal-shim'; import { HealthcareService } from 'fhir/r4'; import { Stethoscope } from 'lucide-react'; // Full, searchable list of the org's services in a modal (replaces the old heavy "View all" services page, // which still carried location/availability/contact fields we retired in the consolidation work). interface ServicesListModalProps { services: HealthcareService[]; onSelect: (service: HealthcareService) => void; onRequestClose: () => void; } // Don't fire the filter until the 3rd character is typed. const MIN_FILTER_CHARS = 3; const ServicesListModal = ({ services, onSelect, onRequestClose }: ServicesListModalProps) => { const [query, setQuery] = useState(''); const filtered = useMemo(() => { const trimmed = query.trim().toLowerCase(); if (trimmed.length < MIN_FILTER_CHARS) return services; return services.filter((service) => (service.name ?? '').toLowerCase().includes(trimmed)); }, [services, query]); return (
{filtered.length === 0 ? (
{services.length === 0 ? 'No services added yet.' : 'No services match your search.'}
) : ( filtered.map((service) => ( )) )}
); }; export default ServicesListModal;