import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { TriangleAlert } from 'lucide-react'; import type { ProviderReadiness } from '../../utils/practitionerBookingReadiness'; import { blockerCopy } from '../../utils/booking/bookabilityCopy'; import { formatFhirHumanName } from '../../utils/fhirHumanName'; export type ProviderReadinessAlertProps = { providers: ProviderReadiness[]; /** The services could not be verified, so some providers' readiness is not known: said once, with Retry. */ servicesUnverified?: boolean; onRetry?: () => void; }; // Copy comes from the shared module so the alert, the authoring consequence lines and the why-not panel all // say the SAME sentence for the same cause - two phrasings read as two different problems. The first blocker // is the one to fix first, so it is the one shown. // THE BLOCKER IS CONSULTED FIRST, and the comment above used to describe behaviour this function did not // have. `hasAnySchedule` was tested BEFORE the blocker list, so a provider missing both a seat and a // schedule was told about the schedule - the one thing that would not help. A seat is band 1 precisely // because fixing anything below it changes nothing. const gapLabel = (provider: ProviderReadiness): string => { const [first] = provider.blockers; if (first) return blockerCopy(first); if (!provider.hasAnySchedule) return 'No schedule set up yet'; return 'Not bookable'; }; const ProviderReadinessAlert = ({ providers, servicesUnverified, onRetry }: ProviderReadinessAlertProps) => { const navigate = useNavigate(); const [open, setOpen] = useState(false); if (providers.length === 0 && !servicesUnverified) return null; return (
We could not check this practice’s services, so whether some providers can take appointments is not known yet. {onRetry && }
)} {providers.length > 0 && (<> {open && (