1
0
Fork 0
Commit Graph

62 Commits

Author SHA1 Message Date
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 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 c236e61692 feat: add root layout, role-based navigation and dashboard 2026-07-04 16:14:53 +02:00
Jonny 63866f7f50 feat: add login page with server action and validation 2026-07-04 15:47:54 +02:00
Jonny 704fb83a58 chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00