import { Link, Outlet, useLocation } from 'react-router-dom'; import { formatDayMonthYear } from '../../../../utils/dateUtils'; import { MSA_ROUTE, type MsaEntry } from '../../../../utils/msaAgreement'; // What the owner can still reach while an MSA update is overdue: the agreement itself, their profile and support. // Signing out is an action, not a page. Nobody else's entry is ever restricted. const SERVED_WHILE_OVERDUE = [MSA_ROUTE, '/dashboard/profile', '/dashboard/support']; const servedWhileOverdue = (path: string) => SERVED_WHILE_OVERDUE.some((served) => path === served || path.startsWith(served + '/')); /** * The owner's practice entry against the MSA: a notice while an update can still be accepted, the practice pages held * until acceptance once its date has passed, and a retry notice when standing could not be read. It never says either * agreement expired: an overdue update is an acceptance still owed. */ const MsaOwnerGate = ({ entry, onRetry }: { entry: MsaEntry; onRetry: () => void }) => { const { pathname } = useLocation(); const onAgreement = pathname === MSA_ROUTE; if (entry.kind === 'restricted' && !servedWhileOverdue(pathname)) { return (
Updated agreement acceptance required. As the practice owner, accept the updated Master Subscription Agreement to continue. Your staff can keep working, and your Business Associate Agreement is unchanged. Review and accept
); } return ( <> {entry.kind === 'notice' && !onAgreement && (
MSA update available: accept by {formatDayMonthYear(entry.deadline)}. Review it
)} {entry.kind === 'retry' && !onAgreement && (
We could not check your Master Subscription Agreement just now.
)} ); }; export default MsaOwnerGate;