import { Navigate, Outlet, useLocation } from "react-router-dom";
import type { ClosureGate } from "../../../../services/PracticeClosureService";
import { NOTICE_TONE, PRACTICE_CLOSURE_PATH } from "./closureText";
// All a closed practice still serves its staff; signing out is an action, not a page.
const SERVED_WHILE_CLOSED = [PRACTICE_CLOSURE_PATH, "/dashboard/support"];
const servedWhileClosed = (path: string) =>
SERVED_WHILE_CLOSED.some((served) => path === served || path.startsWith(`${served}/`));
/**
* The staff route boundary for a closed practice: it decides before any page under it mounts or reads.
* An unreadable closure counts as closed and lands on the closure page, which says it could not be read.
*/
const ClosedPracticeGate = ({ state, onRetry }: { state: ClosureGate; onRetry?: () => void }) => {
const { pathname } = useLocation();
if (state === "open" || servedWhileClosed(pathname)) return
Checking…
; if (state === "unconfirmed") { return (