mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
feat(vaccinations): add the immunization log route, nav entry and shared-record family
- register /vaccinations in the clinical nav spine, module-gated on vaccinations (default-on) and part of the shared record - join /vaccinations to the profile shared-record route family so a scoped profile grant can present the page it is allowed to read - add the page shell: authenticated, module-gated, with the standard module-off redirect the medications surface uses - add the nav label and the surface title/subtitle/empty copy in six locales
This commit is contained in:
1 parent
11a6bc40c0
commit
eefc151617
11 files changed
+176
-2
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { useRecordCapabilities } from "@/hooks/use-record-capabilities";
|
||||
import { PageAuthGate } from "@/components/ui/page-auth-gate";
|
||||
import { VaccinationsView } from "@/components/vaccinations/vaccinations-view";
|
||||
|
||||
/**
|
||||
* v1.38.0 — the immunization log entry.
|
||||
*
|
||||
* Gated on the resolved `modules.vaccinations` flag from `GET /api/auth/me`.
|
||||
* The module is default-on, so `=== false` is the only state that hides the
|
||||
* surface — an account that never touched the toggle keeps it. An
|
||||
* unauthenticated visitor is bounced to login; an authenticated account that
|
||||
* turned the module off is bounced home (the nav entry is already gone for
|
||||
* them, so this only catches a direct URL hit). The `/api/vaccinations*`
|
||||
* routes stay reachable regardless — the module gate governs the surface, not
|
||||
* the row store — so this is a UX redirect, never the security boundary.
|
||||
*/
|
||||
export default function VaccinationsPage() {
|
||||
const { user, isLoading, isAuthenticated } = useAuth();
|
||||
const { inSharedRecord } = useRecordCapabilities();
|
||||
const router = useRouter();
|
||||
|
||||
// Default-on: hidden only when the resolved map says `false` explicitly. A
|
||||
// shared-record session always sees it — the delegate's own module map does
|
||||
// not govern the owner's record.
|
||||
const enabled = inSharedRecord || user?.modules?.vaccinations !== false;
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoading) return;
|
||||
if (!isAuthenticated) {
|
||||
router.push("/auth/login");
|
||||
} else if (!enabled) {
|
||||
router.push("/");
|
||||
}
|
||||
}, [isLoading, isAuthenticated, enabled, router]);
|
||||
|
||||
if (isLoading || !isAuthenticated || !enabled) {
|
||||
return <PageAuthGate />;
|
||||
}
|
||||
|
||||
return <VaccinationsView />;
|
||||
}
|
||||
Reference in new issue
Block a user