1
0
Fork 0
Commit Graph

160 Commits

Author SHA1 Message Date
Jonny 3f78e4f65a feat: add Nutzerverwaltung server actions (erstellen, rolle aendern, sperren, entsperren) 2026-07-15 10:54:08 +02:00
Jonny 02c9274c13 fix: paginate auth.admin.listUsers() in Nutzerliste query 2026-07-15 10:42:24 +02:00
Jonny 3013a7d52c feat: add Nutzerliste query (merges profiles with auth.admin.listUsers) 2026-07-14 22:08:04 +02:00
Jonny 371312fc89 test: add exact 8-character password boundary case 2026-07-14 22:04:32 +02:00
Jonny 147f601e34 feat: add validation for Nutzer-Erstellen, Rolle and Selbstschutz 2026-07-14 22:00:27 +02:00
Jonny 8db31c72a8 feat: add Supabase admin client and service-role-key wiring 2026-07-14 21:56:15 +02:00
Jonny 90ed4d764f fix: unify Zeiterfassung timezone display and add DB guard against double clock-in
Page and CSV export now both render shift timestamps in Europe/Berlin
consistently (previously CSV used UTC, page used server-local time,
causing the same shift to show different clock times in each place).
Also adds a partial unique index so two near-simultaneous Kommen
requests for the same fahrer can no longer create two open shifts --
the existing app-layer check was check-then-act with no DB backstop.
2026-07-14 10:27:50 +02:00
Jonny d87e881d0e feat: add Zeiterfassung link to navigation 2026-07-14 09:11:39 +02:00
Jonny 02dfc2b23e feat: add Zeiterfassung page with Kommen/Gehen, Korrektur and CSV export 2026-07-14 09:03:57 +02:00
Jonny c3cdfc9ac7 feat: add Zeiterfassung server actions (kommen, gehen, korrigieren, csv export) 2026-07-14 08:51:53 +02:00
Jonny d8ccdc85ca feat: add Zeiterfassung query helpers (Schichten, offene Schichten, verknuepfte Auftraege) 2026-07-14 08:45:27 +02:00
Jonny b1da32ae7a test: add bare-CR quoting case for CSV export 2026-07-13 17:11:44 +02:00
Jonny 45612501df fix: harden CSV export against formula injection and CR row corruption
Fields starting with =, +, -, @, tab, or CR are now neutralized with a
leading single quote before quoting, closing a CSV/spreadsheet formula
injection gap (CWE-1236) flagged by automated security review. Also
closes a bare-CR gap in the RFC 4180 escape trigger set.
2026-07-13 17:02:07 +02:00
Jonny 9f2b2d292e feat: add CSV export helper for Zeiterfassung 2026-07-13 16:57:21 +02:00
Jonny b8a7509363 feat: add Tages-/Wochensummen aggregation for Zeiterfassung 2026-07-13 16:51:40 +02:00
Jonny 070b1287c1 test: add invalid-date case for validateSchichtKorrektur 2026-07-13 16:48:51 +02:00
Jonny d91765bd69 feat: add validation for Schicht-Korrektur (geht_um after kommt_um) 2026-07-13 16:44:30 +02:00
Jonny 3fe33c5e0f feat: add pure pause/netto time calculation per §4 ArbZG 2026-07-13 16:31:35 +02:00
Jonny 23ab39bbe9 fix: add keyboard drag support and hide drag handles for readonly role
- KeyboardSensor zu useSensors ergänzt, damit Kanban-Karten auch per
  Tastatur verschoben werden koennen (Design-Spec fordert Maus/Touch/
  Tastatur-Bedienung).
- KanbanKarte erhaelt rolle-Prop; fuer rolle "readonly" werden
  useDraggable-listeners/attributes nicht angewendet (disabled: true),
  sodass keine Drag-Handles/Grab-Cursor angezeigt werden. Navigation zur
  Detailseite bleibt unveraendert klickbar.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-08 13:42:00 +02:00
Jonny a82e31d75e feat: wire Kanban board into the dashboard page 2026-07-08 08:21:13 +02:00
Jonny d873d6d97b feat: add Fahrer-Auswaehler dialog for Disponent/Admin assignment 2026-07-08 08:11:17 +02:00
Jonny 3f77f10520 feat: add KanbanBoard with drag-and-drop for offen->zugewiesen (fahrer) and ->storniert 2026-07-08 07:36:38 +02:00
Jonny f62ef64863 feat: add Kanban board server actions (result-based, no redirect) 2026-07-07 21:45:24 +02:00
Jonny d0017a45b1 feat: add Kanban query helpers (grouped by status, fahrer list) 2026-07-07 21:35:59 +02:00
Jonny 4c0b9772f2 feat: add pure permission helper for Kanban drag targets 2026-07-07 19:39:37 +02:00
Jonny 1c5b2a107f chore: merge duplicate mutations import in stammdaten actions
Found by the final whole-branch review — two separate import
statements from the same module (accumulated across Tasks 4 and 5).
Cosmetic only, no behavior change.
2026-07-07 14:45:12 +02:00
Jonny 116e78fdc6 feat: add inline Fahrzeug quick-add to Auftrag-anlegen page
Adds createFahrzeugUndAuswaehlen (unbound server action) so a new
Fahrzeug can be created inline from /auftraege/neu without leaving
the page, mirroring the existing Ort quick-add flow from Task 6.
Includes an app-layer admin/disponent role check as defense-in-depth
alongside RLS, consistent with the pattern already applied to
createOrtUndAuswaehlen and the page-level gate.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-07 09:39:38 +02:00
Jonny e55ab12c2b fix: add defense-in-depth role check to createOrtUndAuswaehlen 2026-07-07 09:13:29 +02:00
Jonny 69c22f9afe feat: add inline Ort quick-add to Auftrag-anlegen page 2026-07-07 08:47:42 +02:00
Jonny 08184d2166 fix: add defense-in-depth role check to Stammdaten server actions 2026-07-07 08:21:50 +02:00
Jonny 1e7415c81c feat: add Fahrzeuge section to Stammdaten page 2026-07-06 20:20:47 +02:00
Jonny 36c941cad9 feat: add Stammdaten page with Orte list, create and edit 2026-07-06 20:01:40 +02:00
Jonny d8990ba57b feat: add query and mutation helpers for orte and fahrzeuge 2026-07-06 19:35:25 +02:00
Jonny 4795ea1f32 feat: add validation helpers for orte and fahrzeuge 2026-07-06 19:31:33 +02:00
Jonny 06e115cc05 fix: resolve nested <main> landmarks, nav touch targets, focus consistency 2026-07-06 13:17:51 +02:00
Jonny ae78bcaab2 feat: restyle Auftrag-anlegen page 2026-07-06 12:49:29 +02:00
Jonny 55f19858d7 feat: restyle Auftrag detail page 2026-07-06 12:37:35 +02:00
Jonny 4de4482c88 feat: add StatusBadge and restyle Aufträge list page
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-06 12:20:50 +02:00
Jonny 1c1699c5f7 feat: restyle dashboard page 2026-07-06 12:09:23 +02:00
Jonny c98e4ef28f feat: add mobile drawer navigation and restyle header 2026-07-06 11:54:02 +02:00
Jonny 11c893e1b9 feat: add UI primitives (Button, Card, Alert, FormField) and restyle login page 2026-07-06 11:37:15 +02:00
Jonny 83cbba1635 fix: remove unspecified .color-palette utility from globals.css 2026-07-06 11:29:03 +02:00
Jonny 2ab34dce92 feat: add Tailwind CSS v4 with Widmann brand tokens and Inter font 2026-07-06 10:05:49 +02:00
Jonny 7f1df79b41 docs: add design-system spec (mobile-first, Widmann-Branding)
Brand tokens (colors, Inter font) extracted directly from widmannbewegt.de's
production CSS; logo SVG saved for later use. Covers layout/nav, reusable
UI primitives, and page-by-page application as a pure presentation-layer
sub-project on top of the existing Fundament and Auftragsverwaltung features.
2026-07-06 09:42:06 +02:00
Jonny c758dd2305 fix: allow schaden photos during unterwegs and close final-review gaps
Final whole-branch review before merging feature/auftragsverwaltung found
two Important and three Minor issues, all fixed in this round:

- auftrag_fotos and storage.objects INSERT policies now split the
  condition: Pflicht-positions still require status = 'zugewiesen', but
  schaden photos may additionally be uploaded while status = 'unterwegs',
  matching the spec's "jederzeit waehrend der Fahrt nachtragen" requirement.
- Added schadenFotoNachtragen server action + a page form so drivers can
  actually use the new mid-trip upload window.
- Added supabase/tests/auftrag_fotos_rls_test.sql (12 pgTAP tests) covering
  SELECT/INSERT RLS on both auftrag_fotos and storage.objects, including the
  new unterwegs-schaden-allowed / unterwegs-pflicht-blocked cases.
- fahrtBeginnen now checks affected row count like fahrtBeenden/stornieren
  instead of only checking `error`.
- /auftraege/neu now gates on role (admin/disponent) via loadProfile(),
  redirecting non-privileged roles back to /auftraege with a visible error
  (which now renders the error query param).
- Renamed the over-long storage INSERT policy name to stay under the 63
  byte Postgres identifier limit.

Migrations were edited in place rather than layered with a new migration,
following the established precedent (55c4ac5) for pre-merge, not-yet-deployed
RLS fixes on this branch.

Verified: npx supabase db reset clean, npx supabase test db 33/33 passing
(was 21), npm run build and npm test green in web/, and a live rolled-back
SQL probe confirming a driver can insert a schaden photo but not a Pflicht
photo while status = 'unterwegs'.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-06 06:57:22 +02:00
Jonny 58e34a14a6 fix: close stornieren RLS gap and harden fahrtBeenden/stornieren
Security review (automated scan + Task 11 reviewer) found a fahrer could
storniere their own assigned order because Task 2's fahrer UPDATE policy
only constrains zugewiesen_an, never status. Adds a role-gated check to
the status trigger (only admin/disponent may set status='storniert') plus
a pgTAP regression test. Also hardens fahrtBeenden/stornieren to check
affected-row counts instead of silently redirecting to a success page on
a blocked update.

Live-verified: fahrer storno attempt now rejected by the trigger; normal
fahrer fahrtBeenden flow unaffected. db reset + test db (21/21), build,
and npm test (17/17) all pass.
2026-07-06 06:22:53 +02:00
Jonny 4459a6cfcb feat: add fahrt-beenden, stornieren and folgeauftrag suggestion
Adds fahrtBeenden (unterwegs -> abgeschlossen with end_km validation)
and stornieren (any non-terminal status -> storniert) Server Actions,
plus findeFolgeauftrag to surface a linked follow-up order on the
detail page once an order is abgeschlossen.

kannStornieren uses a local admin/disponent role check rather than
canManageUsers, since the latter is scoped to user management and
would incorrectly hide the storno action from disponents.
2026-07-05 22:36:19 +02:00
Jonny 89564e527d feat: add auftrag detail page with uebernehmen and fahrt-beginnen actions
fahrtBeginnen uses plain insert (not upsert) for auftrag_fotos writes:
the partial unique index from Task 3 (where position <> 'schaden') can't
be targeted by PostgREST's onConflict option (Postgres 42P10), and
fahrer have no UPDATE grant on auftrag_fotos anyway, so an upsert's
DO UPDATE branch could never succeed for them. Verified live against
the local Supabase stack that the original upsert-based approach
silently wrote zero photo rows, blocking every real fahrtBeginnen
attempt at the DB trigger.
2026-07-05 22:16:54 +02:00
Jonny d292d122c9 feat: add auftraege list page with role-aware sections 2026-07-05 21:45:27 +02:00
Jonny e85e9ce993 feat: add auftrag creation page and server action 2026-07-05 17:49:48 +02:00
Jonny 36e65cad48 feat: add server-side data access helpers for auftraege 2026-07-05 17:32:05 +02:00
Jonny 225504f3a9 feat: add fahrt validation helpers for km and required photos 2026-07-05 17:20:40 +02:00
Jonny bf7af326f4 docs: add root setup README and fix stale auth.user_role() reference
There was no end-to-end runbook for getting from a fresh clone to a
running dev environment -- the sequence was scattered across script
comments and .env.example. Add a root README.md covering secrets
generation, template rendering, docker compose up, migrations, first
admin user creation, and the non-Docker web/ dev alternative, plus a
heads-up that the admin@aushilfsfahrer.local test password was reset
out-of-band during implementation and isn't recorded anywhere.

Replace web/README.md's untouched create-next-app boilerplate (which
mentioned yarn/pnpm/bun and "Deploy on Vercel") with a one-line pointer
to the root README, since it was actively misleading for this
self-hosted Docker project.

Also fix the design spec still naming the helper auth.user_role() --
it was renamed to public.user_role() during Task 3 due to the
auth-schema lockdown; the migrations and plan already reflect this.
2026-07-05 00:45:39 +02:00
Jonny d812db7da3 fix: fall back to NEXT_PUBLIC_SUPABASE_URL when SUPABASE_INTERNAL_URL is unset
Adds graceful degradation for environments that don't have SUPABASE_INTERNAL_URL
configured. Uses nullish coalescing to fall back to NEXT_PUBLIC_SUPABASE_URL if
the new internal URL variable is unset, maintaining backward compatibility while
preserving the Docker-specific optimization.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-05 00:29:35 +02:00
Jonny 2f508ea5dd feat: containerize the Next.js app and wire it into docker-compose
Adds web/Dockerfile (multi-stage node:22-alpine build, standalone output)
and web/.dockerignore, and wires a `web` service into docker-compose.yaml
so the whole stack (self-hosted Supabase + Next.js) starts with a single
`docker compose up -d`.

Networking fix: Next.js inlines NEXT_PUBLIC_* env vars at build time into
every compiled bundle, including server-side ones (Server Actions, Server
Components, Middleware) - not just the browser bundle. Since
NEXT_PUBLIC_SUPABASE_URL must point at the externally-reachable
http://localhost:8000 for the browser, the server-side Supabase clients in
lib/supabase/server.ts and lib/supabase/middleware.ts got that same literal
baked in - which resolves to the web container itself (not kong) once
running in Docker, causing ECONNREFUSED on any server-side Supabase call
(most visibly signInWithPassword in the login server action).

Fix: introduce SUPABASE_INTERNAL_URL, a server-only env var without the
NEXT_PUBLIC_ prefix, so it's read at actual runtime rather than inlined at
build time. It points at http://kong:8000 in docker-compose.yaml (same
pattern already used by the studio service's internal SUPABASE_URL) and at
http://localhost:8000 in web/.env.local(.example) for non-Docker local dev,
where there's no container networking boundary. lib/supabase/client.ts
(browser-only) is untouched and keeps reading NEXT_PUBLIC_SUPABASE_URL.

Considered extra_hosts: ["localhost:host-gateway"] instead, but rejected it:
overriding what the literal string "localhost" resolves to inside a
container is unreliable (glibc's resolver typically still prioritizes the
container's own loopback), and is the kind of workaround that looks fixed
in a quick check and quietly breaks later.

Verified end-to-end against the running container via curl (unauth redirect,
real signInWithPassword through the login server action, authenticated
dashboard content, logout) with zero ECONNREFUSED in `docker compose logs
web` afterward, plus a local `npm run dev` smoke test to confirm non-Docker
development still works unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-05 00:25:01 +02:00
Jonny c236e61692 feat: add root layout, role-based navigation and dashboard 2026-07-04 16:14:53 +02:00
Jonny b397cb326b feat: add auth middleware with session refresh and redirects 2026-07-04 15:57:41 +02:00
Jonny 63866f7f50 feat: add login page with server action and validation 2026-07-04 15:47:54 +02:00
Jonny 7254923885 feat: add Supabase browser and server client helpers
- Add browser client helper (createClient) for client-side components
- Add server client helper (createClient) for server components and route handlers
- Add test for browser client functionality
- Update .gitignore to allow .env.local.example while ignoring .env*.local
- Install @supabase/supabase-js and @supabase/ssr packages

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 15:32:05 +02:00
Jonny 704fb83a58 chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00