import React from 'react'; import { useAuthServiceContext } from '../../../services'; import { PatientsPanel } from '../StaffMessagesPage/panels/PatientsPanel'; import { MESSAGES_PAGE_HEIGHT } from '../../../utils/messagesLayout'; // Retained only for the per-patient-chart `communication-requests` route mount. Renders the shared // PatientsPanel (chrome on, since there is no shell here). // // (design-pass finding B23) - THIS IS THE THIRD STAFF-ONLY LEAF IN A SHARED ROUTE TREE, and // the first one that REDIRECTED instead of rendering nothing. // // `communication-requests` is declared inside `renderPatientRoutes()` (App.tsx), which the patient-SELF // portal mounts as well as the staff chart. This page is staff-only, so a patient reaching it used to be // bounced by `useRouteAuthorization({ allowedRoles: [PRACTITIONER, RECEPTIONIST] })` - and that guard // navigates to '/', which for a patient is the dashboard home. The observed symptom was the DASHBOARD // rendering under a "My Records" breadcrumb: not a routing table fault, a guard doing exactly what it // was told on a route it should never have been reachable on. // // Now it follows the pattern the two prior instances already established - `PatientNotesSection` and // `PatientAccessLogSection` in App.tsx, both of which return null for a patient rather than redirecting, // and both of whose headers explain that this route tree is shared. Rendering nothing is honest and // stays put; navigating somewhere else asserts that the somewhere-else IS this route. // // What a patient SHOULD see at this path is a product question, not a routing one - they have their // own Messages surface at /dashboard/messages. Raised for the design pass rather than guessed at here. const PatientMessagesPage: React.FC = () => { const { currentUser, USER_ROLES } = useAuthServiceContext(); const isPatient = [USER_ROLES.PATIENT, USER_ROLES.RELATED_PERSON].includes( currentUser?.fhir?.resourceType as string, ); if (isPatient) return null; // The panel's split fills its parent, so this mount states the height the staff shell states // for the other one. Without it the split has no box to fill. return (