5.4 KiB
5.4 KiB
Implementation Plan
Checklist
-
Reconcile existing Drizzle migration state:
- Confirm
modules/core/server/schema.tsmatchesdrizzle/migrations. - Confirm
modules/core/server/db.tsis the only PostgreSQL connection boundary. - Confirm
modules/core/server/store.tsis treated as a compatibility read model only. - Remove task assumptions that mention JSON file writes as the target persistence layer.
- Confirm
-
Verify existing auth/RBAC/audit slice:
- Confirm setup creates platform admin, organization, session, organization roles, membership, and audit log.
- Confirm login/logout uses server APIs and the
teatea_sessionHTTP-only cookie. - Confirm
requirePermissionlogs denied permission checks. - Confirm roles and permissions cover facility and admission operations.
-
Finish elder CRUD on Drizzle:
- Keep validation in
modules/elders/types.ts. - Ensure list/create/update/delete APIs query and mutate Drizzle only.
- Ensure elder create with
bedIdperforms admission and bed status updates inside a transaction. - Ensure UI refresh and error handling remain usable.
- Keep validation in
-
Add or complete bed/admission APIs:
- Keep
GET /api/facilities/roomsandGET /api/facilities/bedsDrizzle-backed. - Keep
POST /api/admissionstransactional for admit/transfer. - Add discharge and explicit transfer mutation support if the existing POST shape is not enough.
- Return structured
{ success, reason, ... }responses for conflicts and validation failures. - Write audit events for admission create, transfer, discharge, and facility mutations implemented in this task.
- Keep
-
Build bed/admission UI:
- Replace "please create through API" empty states with usable controls where permission allows.
- Add tabs or segmented navigation for overview, bed status, admission actions/history, and facility records.
- Move admission actions into the bed/admission workspace.
- Remove or replace the dead global top-bar "入住" button in
AppShell. - Ensure page layout matches screenshot feedback: compact workspace header, no oversized intro block, local page actions.
-
Introduce selected Phase 2 UI affordances:
- Add tabs to pages that combine overview and management modes.
- Keep implementation incremental; do not attempt every sidebar module.
- Keep user-facing copy operational and concise.
-
Add standard chart usage:
- Decide the chart library before adding dependency. Recharts is the likely default unless a better project fit is chosen.
- Install the library only after checking existing dependencies.
- Replace at least one meaningful hand-built chart with a data-backed chart component.
- Keep chart component client-only and pass serializable server data into it.
-
Replace hard-coded operational counters where data exists:
- Dashboard bed/elder/admission counters should come from Drizzle-backed data.
- Bed/admission workspace metrics should compute from server-loaded rooms, beds, and admissions.
- Do not fabricate counters for modules that remain out of scope.
-
Verification:
- Run
pnpm lint. - Run
pnpm type-check. - Run
pnpm build. - Run Drizzle generation/check commands when schema changes are made.
- Start dev server and manually exercise setup/login/elder CRUD/bed admission/transfer/discharge/settings if build passes.
- Run
Files Expected to Change
.trellis/tasks/07-01-nextjs-fullstack-crud-rbac-audit/prd.md.trellis/tasks/07-01-nextjs-fullstack-crud-rbac-audit/design.md.trellis/tasks/07-01-nextjs-fullstack-crud-rbac-audit/implement.mdmodules/shared/components/AppShell.tsxapp/(app)/app/beds/page.tsxapp/(app)/app/dashboard/page.tsxmodules/dashboard/components/DashboardHome.tsxapp/api/admissions/route.ts- Potentially
app/api/admissions/[id]/route.ts - Potentially facility UI components under
modules/if the bed page is split into smaller client/server components.
Files Expected to Stay As Existing Foundations
modules/core/server/db.tsmodules/core/server/schema.tsmodules/core/server/auth.tsmodules/core/server/permissions.tsmodules/core/server/audit.tsmodules/core/server/api.tsmodules/core/server/store.tsas a temporary Drizzle-backed read model.- Existing auth route handlers unless verification finds a concrete bug.
- Existing elder route handlers unless admission or bed assignment behavior requires a narrow fix.
Dependency Notes
- Do not add oRPC or better-auth in this task.
- Do not reintroduce JSON-file persistence.
- A standard chart library may be added after dependency review. Prefer a focused dashboard dependency over a broad visualization stack.
Validation Commands
pnpm lint
pnpm type-check
pnpm build
pnpm db:generate
If schema files are changed, also validate migrations and run the migration flow against the configured development database:
pnpm db:migrate
Rollback Points
- If admission mutation UI is unstable, keep the Drizzle APIs and temporarily render a read-only admissions table.
- If discharge/transfer API design becomes too broad, implement only admission create/transfer in this slice and keep discharge as a clearly scoped follow-up.
- If chart dependency causes build or bundle issues, remove the chart component and keep the server data preparation in place.
- If tabs cause layout regressions, keep the page-local action placement and defer only the tab styling.