import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '../ui/dialog'; import { blockerCopy, byDesignCopy } from '../../utils/booking/bookabilityCopy'; import { byDesignBlockers, gapBlockers, type BookabilityBlocker, } from '../../utils/booking/bookabilityReasons'; // Warns that what you are about to save will not be bookable by a patient. // // IT NEVER BLOCKS THE SAVE. A practice mid-setup legitimately saves a half-configured block, and refusing // would be precisely the "one cog missing unusable" failure this whole program exists to prevent. The point // is that the consequence is stated at the moment of the write, when attention is highest - not that the user // is stopped. // // "Keep editing" is a real choice rather than a Cancel (the house rule is that modals need no Cancel - the X // cancels). Both actions here are meaningful, and for a distracted operator an explicit pair reads better than // a single button plus an implied dismiss. export interface UnbookableSaveDialogProps { open: boolean; blockers: BookabilityBlocker[]; onSaveAnyway: () => void; onKeepEditing: () => void; } const UnbookableSaveDialog = ({ open, blockers, onSaveAnyway, onKeepEditing, }: UnbookableSaveDialogProps) => { const gaps = gapBlockers(blockers); const byDesign = byDesignBlockers(blockers); return ( { // Dismissing is the safe choice: it returns you to the form with nothing saved. if (!next) onKeepEditing(); }} > {/* When every remaining reason is a deliberate self-booking choice, this is NOT unfinished work — no "yet", and no implication that something needs fixing. */} {gaps.length === 0 ? 'Patients won’t be able to self-book this' : 'Patients won’t be able to book this yet'} {gaps.length === 0 ? 'That’s a setting, not a problem — staff can still book it for a patient.' : 'You can save it anyway and finish later — nothing is lost.'} {/* Ordered: the first blocker is the one to fix first. By-design reasons carry the other half of the truth so a deliberate choice never reads as breakage. */}

Other problems, such as a service switched off for the whole organization, may only appear after saving.

{/* Plain
); }; export default UnbookableSaveDialog;