import HowItWorks from "./HowItWorks";
import PatientPage from "./patient/PatientPage";
import PatientsPage from "./patients/PatientsPage";
import { navigate } from "./router";
import { ClinicianGate } from "./session";
import Settings from "./Settings";
import TodayPage from "./today/TodayPage";
function Page({ path }: { path: string }) {
const parts = path.split("/").filter(Boolean).slice(1);
if (parts[0] === "patients" && parts[1]) return <PatientPage key={parts[1]} id={decodeURIComponent(parts[1])} segments={parts.slice(2)} />;
if (parts[0] === "patients") return <PatientsPage />;
if (parts[0] === "settings") return <Settings section={parts[1]} />;
if (parts[0] === "how-it-works") return <HowItWorks />;
// /app and any unknown /app/* address open Today.
if (parts[0] !== "today" || parts.length > 1) queueMicrotask(() => navigate("/app/today", { replace: true }));
return <TodayPage />;
}
/** Everything under /app: the signed-in clinician's screens behind the session gate. */
export default function AppRoutes({ path }: { path: string }) {
return (
<ClinicianGate path={path}>
<Page path={path} />
</ClinicianGate>
);
}