import { Link, useLocation } from "@tanstack/solid-router"; import { type ParentProps, Show } from "solid-js"; import { IconHome, IconPackage } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; import { moduleLabel } from "@/lib/module-labels"; import { routeModule } from "@/lib/route-module"; import { useModules } from "@/stores/modules-context"; import { useT } from "@/stores/preferences-context"; /** * Stands in for a page whose module the school has switched off. Without it * the page mounts, every call 403s, and the user lands on a blank or error * screen — typically from a bookmark, a stale tab, or a module turned off * mid-session. Unknown module state (loading, lookup failed) renders the page. */ export function ModuleGate(props: ParentProps) { const t = useT(); const location = useLocation(); const modules = useModules(); const off = () => { const module = routeModule(location().pathname); const enabled = modules.enabled(); return module && enabled && !enabled.includes(module) ? module : null; }; // Until the school's list arrives a module page would fire its reads blind; // a spinner for that first beat keeps an off module from ever being asked. return ( }> {(module) => (

{t("modules.offTitle", { module: moduleLabel(module(), t) })}

{t("modules.offDescription")}

{t("common.goHome")}
)}
); }