/** * WHAT THE SEAT-REMOVAL DIALOG SAYS WHEN IT COULD NOT READ THE CALENDAR. * * The dialog looks a clinician's upcoming appointments up as a COURTESY, so that an administrator taking * a seat away is told how many patients are booked with somebody about to stop being bookable. When that * read fails the removal still goes ahead, because whoever may grant a seat must be able to remove one - * but the reader is asked to make the check themselves first. * * ASKING THEM TO CHECK IS ONLY HONEST IF THEY CAN. HR is the case that proves it: the read fails for * them precisely because their role may not see appointments, and no surface in their workspace shows * another practitioner's bookings. Telling that person to "open their calendar first" and then asking * them to confirm they did produces a tick box on a guess - stronger-looking than saying nothing, and * weaker than it appears, on an action that stops a recurring charge and can strand a booked patient. * * So the ask changes with what the reader can actually reach, and only the ask: * * - a reader who may see other people's schedules is told to look, and confirms they looked. * - a reader who may not is told plainly that nobody with their permissions can check this, is told what * they are risking, and accepts THAT. It is weaker protection and it is true, where the other sentence * is stronger protection and is not. * * NEITHER ARM EVER ASSERTS AN EMPTY CALENDAR. That is the false reassurance the whole guard exists to * prevent, and it is what makes an unseat feel safe when it is not. * * A module for four strings for the same reason `schedulesScopeCopy` is one: the wording IS the fix here, * and an invariant - no arm tells a reader to look at something they cannot open - is checkable as a * value and unholdable as a ternary inside a dialog. */ export interface SeatRemovalUnknownCalendarCopy { /** What could not be done, and that the removal is not blocked by it. */ lead: string; /** What to do about it, or what is being accepted instead. */ body: string; /** The tick box. It must name something the reader can actually have done. */ acknowledgement: string; } /** * The sentence that must never reach either arm: we did not look, so we do not get to say what is there. * Exported so the guard asserts against this rather than carrying its own copy of the string and * drifting from the module. */ export const FALSE_REASSURANCE = 'no upcoming appointments'; export const seatRemovalUnknownCalendarCopy = ( staffName: string, canSeeOtherPeoplesSchedules: boolean, ): SeatRemovalUnknownCalendarCopy => (canSeeOtherPeoplesSchedules ? { lead: "Could not check this clinician's upcoming appointments. You can still remove the seat.", body: 'Existing appointments are not moved or cancelled automatically. We do not know whether ' + `${staffName} has any. Open ${staffName}'s schedule and check before removing the seat.`, acknowledgement: `I have checked ${staffName}'s schedule myself.`, } : { lead: "Could not check this clinician's upcoming appointments, and your role cannot view them. " + 'You can still remove the seat.', body: 'Existing appointments are not moved or cancelled automatically. If ' + `${staffName} has any, those patients stay booked with a clinician who cannot open their ` + 'visit. Someone at the practice must move or cancel those appointments. Ask someone with ' + 'schedule access if you want to check first.', acknowledgement: `Remove the seat anyway. I accept that ${staffName} may have patients booked.`, });