diff --git a/src/components/layout/auth-shell.tsx b/src/components/layout/auth-shell.tsx index f03f531e4..f6159f081 100644 --- a/src/components/layout/auth-shell.tsx +++ b/src/components/layout/auth-shell.tsx @@ -28,8 +28,8 @@ import { OfflineBanner } from "./offline-banner"; import { SharedRecordBanner } from "./shared-record-banner"; import { SharedRecordUnavailable } from "./shared-record-unavailable"; import { - isModulePageOff, ModulePageGate, + switchedOffModule, } from "@/components/layout/module-page-gate"; import { cn } from "@/lib/utils"; import { isOnboardingPathname } from "@/lib/onboarding/wizard-steps"; @@ -158,7 +158,7 @@ export function AuthShell({ const fullBleed = pathname === COACH_FULL_BLEED_PATH && !outsideSharedRecord && - !isModulePageOff(pathname, user?.modules); + switchedOffModule(pathname, user?.modules) === undefined; // The whole setup flow, not only its front door: every screen lives under // `/onboarding/` (v1.39 C2), and an exact match here put the // questions inside the full app chrome, sidebar and all. diff --git a/src/components/layout/module-page-gate.tsx b/src/components/layout/module-page-gate.tsx index 6d75d4efd..db0a8d35e 100644 --- a/src/components/layout/module-page-gate.tsx +++ b/src/components/layout/module-page-gate.tsx @@ -56,6 +56,21 @@ export function moduleOwningPath(pathname: string): ModuleKey | undefined { return destination ? navDestinationModule(destination) : undefined; } +/** + * The module that owns `pathname` when it is switched off, otherwise + * undefined. The shell reads it too: a switched-off page renders the + * notice in the ordinary padded frame. + */ +export function switchedOffModule( + pathname: string, + modules: Partial> | null | undefined, +): ModuleKey | undefined { + const moduleKey = moduleOwningPath(pathname); + return moduleKey !== undefined && modules?.[moduleKey] === false + ? moduleKey + : undefined; +} + /** * A page of a module that is switched off answers with an inline notice that * names the reason, in one place for every module page: top-level pages @@ -74,24 +89,13 @@ export function moduleOwningPath(pathname: string): ModuleKey | undefined { * only after the account payload resolved, so the map is never read on a * hydration render. */ -/** True when the module that owns `pathname` is switched off. */ -export function isModulePageOff( - pathname: string, - modules: Partial> | null | undefined, -): boolean { - const moduleKey = moduleOwningPath(pathname); - return moduleKey !== undefined && modules?.[moduleKey] === false; -} - export function ModulePageGate({ children }: { children: ReactNode }) { const pathname = usePathname(); const { user } = useAuth(); const { t } = useTranslations(); - const moduleKey = moduleOwningPath(pathname); - if (moduleKey === undefined || !isModulePageOff(pathname, user?.modules)) { - return <>{children}; - } + const moduleKey = switchedOffModule(pathname, user?.modules); + if (moduleKey === undefined) return <>{children}; const destination = NAV_DESTINATIONS.find((d) => isNavDestinationActive(d.href, pathname),