docs(admin): phase 3a session log + roadmap status
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Insole Production Time Tracker — Rebuild Roadmap & Project Overview
|
||||
|
||||
- **Created:** 2026-06-17
|
||||
- **Status:** Approved — living project doc; Phases 0–2 implemented (`docs/plans/phase-2-accounts-roles.md`)
|
||||
- **Status:** Approved — living project doc; Phases 0–2 implemented + Phase **3a** implemented (`docs/superpowers/plans/2026-06-17-phase-3a-admin-panel.md`)
|
||||
- **Type:** Greenfield rebuild of an inherited app
|
||||
- **Tracked in git** under `docs/` (the project's documentation source of truth).
|
||||
|
||||
@@ -174,8 +174,16 @@ Each phase keeps the system working and is its own spec → plan → build cycle
|
||||
an admin account exists; admin manages users via `/api/auth/admin/*` and sees all sessions via
|
||||
`/api/admin/sessions`. Public sign-up is closed; activity writes are admin-only.
|
||||
_Done when:_ workers see only their own sessions; an admin account exists.
|
||||
- **Phase 3 — Admin panel.** The React admin app: live active-work view, reports/export,
|
||||
user management, **activity management**, **manual entry/edit (the fallback)**.
|
||||
- **Phase 3 — Admin panel.** The React admin app (`apps/admin`, Vite + React, dev port
|
||||
5174): live active-work view, reports/export, user management, **activity management**,
|
||||
**manual entry/edit (the fallback)**.
|
||||
**3a implemented** (`apps/admin`; plan `docs/superpowers/plans/2026-06-17-phase-3a-admin-panel.md`):
|
||||
admin-only login (rejects non-admins via `role` on `/api/me`), the sidebar shell, the live
|
||||
active-work view (`/api/admin/sessions/active`, 5 s auto-refresh, read-only), and activity
|
||||
management (handelingen CRUD on `/api/activities`). **3b remaining:** reports/export
|
||||
(all-users filtered CSV — current `/api/export` is self-scoped), user management
|
||||
(better-auth `/api/auth/admin/*`), and manual entry/edit + admin stop/fix of a running
|
||||
session (needs new backend endpoints).
|
||||
Activity management (add/edit/delete handelingen + their `insole_types`) was removed from the
|
||||
worker client in the Phase 2 follow-up because it is admin-only; it must be **ported here**. The
|
||||
backend already exists (`/api/activities` writes are admin-gated; `useActivities`/the legacy
|
||||
|
||||
72
docs/sessions/2026-06-17-phase-3a-admin-panel.md
Normal file
72
docs/sessions/2026-06-17-phase-3a-admin-panel.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Session: 2026-06-17 — Phase 3a (Admin panel MVP)
|
||||
|
||||
## Goal
|
||||
|
||||
Build `apps/admin`: a Vite + React desktop SPA where an admin logs in, watches who is
|
||||
working **live** (auto-refreshing, read-only), and manages **handelingen** (activities).
|
||||
Everything rides on existing backend endpoints plus one tiny backend touch (`role` on
|
||||
`/api/me`). Reports/export, user management, and manual session entry/edit are deferred to
|
||||
Phase 3b. Spec: `docs/superpowers/specs/2026-06-17-phase-3a-admin-panel-design.md`;
|
||||
plan: `docs/superpowers/plans/2026-06-17-phase-3a-admin-panel.md`.
|
||||
|
||||
## Work done
|
||||
|
||||
Implemented Phase 3a task-by-task per the plan (TDD throughout):
|
||||
|
||||
- **Task 1 — `role` on `/api/me` + admin-origin CORS** (`02b7522`). Added `role: Role` to
|
||||
`PublicUser` in `@solelog/shared`; `apps/api/src/routes/me.ts` now returns the session
|
||||
user's role (default `'worker'`). Added `http://localhost:5174` (admin dev origin) to the
|
||||
default `WEB_ORIGINS` in `env.ts` + `.env.example` (it drives both `hono/cors` and
|
||||
better-auth `trustedOrigins`). Extended `me.test.ts` and `cors.test.ts`. Worker client
|
||||
ignores the extra field — no worker change needed.
|
||||
- **Task 2 — Scaffold `apps/admin`** (`682a9dc`). New `@solelog/admin` workspace mirroring
|
||||
`apps/worker`'s toolchain (Vite 7, React 18.3, react-router 6, react-query 5, vitest 3,
|
||||
TS 5.7). Copied `lib/api.ts` + `lib/auth-storage.ts` verbatim (shared `solelog.token`
|
||||
key; separate localStorage because the admin runs on a different port). Dev port **5174**.
|
||||
- **Task 3 — Auth context + admin gate + Login** (`77659ed`). `auth/AuthContext.tsx`:
|
||||
`signIn` calls the worker `signIn`, fetches `/api/me`, and rejects non-admins
|
||||
(`clearToken()` + throw) so `Login` shows "Geen toegang — alleen beheerders."; other
|
||||
failures show "Inloggen mislukt".
|
||||
- **Task 4 — Sidebar shell + routing** (`286e2d2`). Left-sidebar shell: brand "SoleLog
|
||||
Admin", `NavLink`s **Live** / **Handelingen**, a muted "Binnenkort" group (Rapporten /
|
||||
Gebruikers / Handmatig) hinting 3b, and a header strip with the signed-in email + an
|
||||
Uitloggen button (`aria-label="Uitloggen"`).
|
||||
- **Task 5 — Live active-work view** (`67dd0d3`). `useActiveSessions()` polls
|
||||
`/api/admin/sessions/active` with `refetchInterval: 5000`; `lib/elapsed.ts` `formatTime`
|
||||
ported verbatim from the worker stopwatch. One card per session (worker name, activity,
|
||||
insole-type pill, pair count, ticking elapsed timer). Header "Actief nu (N)"; empty state
|
||||
"Niemand is nu aan het werk.".
|
||||
- **Task 6 — Activity management** (`c0d9d21`). Ported the legacy worker `Settings.tsx`
|
||||
(git `decb158`) near-verbatim: `api/activities.ts` hooks (`useActivities` +
|
||||
create/update/delete, all invalidating `['activities']`) and `screens/Activities.tsx`
|
||||
(add form with insole-type toggles, list with inline edit, delete-with-confirm). Title
|
||||
"Handelingen".
|
||||
- **Task 7 — Docs, lint, verification** (this task). Lint/format clean, full green matrix,
|
||||
live smoke, docs.
|
||||
|
||||
## Verification (Task 7)
|
||||
|
||||
- `npx oxlint` — clean (exit 0).
|
||||
- `npx oxfmt --list-different` over the phase-3a files — nothing to change (all formatted).
|
||||
- `yarn workspace @solelog/api typecheck` — pass; `test` — **46 passed** (11 files).
|
||||
- `yarn workspace @solelog/admin typecheck` — pass; `test` — **14 passed** (5 files);
|
||||
`build` — pass (`vite build`, 89 modules).
|
||||
- `yarn workspace @solelog/worker test` (regression) — **22 passed** (7 files).
|
||||
- **Live smoke** (API started, seeded, then server tree killed + port 3000 freed):
|
||||
- admin sign-in → `GET /api/me` → `{ ..., "role": "admin" }`.
|
||||
- `GET /api/admin/sessions/active` with the admin bearer → `[]`, HTTP 200.
|
||||
- worker sign-in → `GET /api/me` → `{ ..., "role": "worker" }`.
|
||||
|
||||
## Outcome
|
||||
|
||||
Phase 3a is implemented and green. An admin can sign in to the admin app, see who is
|
||||
working right now (5s auto-refresh, read-only), and add/edit/delete handelingen; a worker
|
||||
who signs in with valid credentials is rejected with "Geen toegang". Roadmap Phase 3 status
|
||||
updated to "3a implemented; 3b remaining"; `apps/admin/README.md` filled.
|
||||
|
||||
## Next (Phase 3b)
|
||||
|
||||
- Reports + all-users filtered CSV export (current `/api/export` is self-scoped).
|
||||
- User management via better-auth `/api/auth/admin/*`.
|
||||
- Manual session entry/edit + admin stop/fix of another worker's session (needs new
|
||||
backend endpoints).
|
||||
Reference in New Issue
Block a user