mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
refactor(v1.5): apply simplify-review safe-to-apply suggestions
Drops dead `id` props and `scroll-mt-28` classes from admin section components (load-bearing in v1.4 monolithic admin, dead since the v1.5 phase-4b dynamic-route split). Also removes the unused `LEGACY_ANCHOR_TO_SLUG` map, the `admin-shell` re-export shim, the `BERLIN_TZ` and duplicate `MS_PER_DAY` constants, the verbose `AdminSectionPage` docstring, the `useEffect` paraphrase comment in `ai-section`, and rewrites the `_exhaustive: never` exhaustiveness guard to the modern `slug satisfies never` form. `UserManagementSection` now reads `currentUserId` via `useAuth()` instead of accepting it as a prop. Findings 1, 2, 3, 4, 6, 7, 8, 11, 15, 16, 17 from .planning/phase-6-simplify-findings.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
79864bb8c2
commit
88c8db1abc
22 files changed
+41
-147
No files matched your search
@@ -7,19 +7,8 @@ import {
|
||||
isAdminSectionSlug,
|
||||
} from "@/components/admin/section-slugs";
|
||||
|
||||
/**
|
||||
* Dynamic admin section route — mirrors the v1.4 settings split. Each of
|
||||
* the `ADMIN_SECTION_SLUGS` is pre-rendered at build via
|
||||
* `generateStaticParams()` so the URLs are statically known to Next.js,
|
||||
* while `dynamicParams = false` tells the router to 404 (rather than
|
||||
* attempting on-demand rendering) for any slug not in the list.
|
||||
*
|
||||
* The actual section components are mounted by the client-only
|
||||
* `<AdminSectionRenderer>` because most of them use TanStack Query and
|
||||
* the auth hook (server-rendered they'd just paint a loader). The shell,
|
||||
* however, is server-rendered so the sidebar paints with no JS hydration
|
||||
* lag.
|
||||
*/
|
||||
// Section bodies need TanStack Query / useAuth, so they're rendered by the
|
||||
// client-only `<AdminSectionRenderer>`. The shell stays server-rendered.
|
||||
|
||||
export const dynamicParams = false;
|
||||
|
||||
@@ -28,16 +17,12 @@ export function generateStaticParams() {
|
||||
}
|
||||
|
||||
interface PageProps {
|
||||
// Next.js 16 made route `params` an async Promise. We `await` it before use.
|
||||
params: Promise<{ section: string }>;
|
||||
}
|
||||
|
||||
export default async function AdminSectionPage({ params }: PageProps) {
|
||||
const { section } = await params;
|
||||
|
||||
// Defence-in-depth — `dynamicParams = false` already 404s unknown slugs at
|
||||
// routing time, but we re-check here so a hand-rolled override of the
|
||||
// route config can never silently fall through to a typo'd slug.
|
||||
if (!isAdminSectionSlug(section)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ export function AdminSectionRenderer({
|
||||
title={t("admin.section.users.title")}
|
||||
subtitle={t("admin.section.users.subtitle")}
|
||||
>
|
||||
<UserManagementSection currentUserId={user.id} />
|
||||
<UserManagementSection />
|
||||
</SectionFrame>
|
||||
);
|
||||
case "api-tokens":
|
||||
@@ -145,12 +145,9 @@ export function AdminSectionRenderer({
|
||||
<DangerZoneSection />
|
||||
</SectionFrame>
|
||||
);
|
||||
default: {
|
||||
// exhaustiveness guard — TS will flag a missing case here
|
||||
const _exhaustive: never = slug;
|
||||
void _exhaustive;
|
||||
default:
|
||||
slug satisfies never;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user