From 1ca696e8cb7fcbb8bc92409944581a530f0d94e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20F=C3=B6rtsch?= Date: Thu, 12 Mar 2026 11:11:28 +0100 Subject: [PATCH] add design spec for step-wise mock data, flow bug fixes Co-Authored-By: Claude Opus 4.6 --- .../2026-03-12-step-wise-mock-data-design.md | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 docs/superpowers/specs/2026-03-12-step-wise-mock-data-design.md diff --git a/docs/superpowers/specs/2026-03-12-step-wise-mock-data-design.md b/docs/superpowers/specs/2026-03-12-step-wise-mock-data-design.md new file mode 100644 index 0000000..0d9cf88 --- /dev/null +++ b/docs/superpowers/specs/2026-03-12-step-wise-mock-data-design.md @@ -0,0 +1,99 @@ +# Step-wise Mock Data & Flow Bug Fixes + +## Problem + +The app has two categories of issues preventing a complete flow-through: + +1. **Data integrity bugs** — process step transitions don't update all relevant `nutzer` fields, so the antrag checklist can never fully complete even when the user follows the happy path. +2. **Mock data gaps** — the existing `seedMockData()` creates a single fixed state (eigensuche with 20 therapists) but doesn't set `nutzer.dringlichkeitscode` or `nutzer.tss_beantragt`, making it impossible to test the full flow or individual steps. + +## Goal + +Fix the flow bugs so the real UI path works end-to-end, and replace the single mock-data button with a step-wise scenario dropdown in dev settings that seeds the complete app state for any given process step. + +## Changes + +### 1. Bug fix: SprechstundeForm (process-stepper.tsx) + +**Current behavior:** `SprechstundeForm.onSubmit` inserts into `sprechstunde` table with `dringlichkeitscode`, then separately updates `nutzer.aktueller_schritt = 'diagnose_erhalten'`. It never writes `nutzer.dringlichkeitscode` or `nutzer.dringlichkeitscode_datum`. + +**Fix:** Replace the two separate queries with a single `sprechstunde` INSERT and a combined `nutzer` UPDATE: + +```sql +UPDATE nutzer SET + aktueller_schritt = 'diagnose_erhalten', + dringlichkeitscode = $1, + dringlichkeitscode_datum = CASE WHEN $1 THEN $2 ELSE NULL END, + aktualisiert_am = NOW() +WHERE id = 1 +``` + +Where `$1` is the dringlichkeitscode boolean and `$2` is the sprechstunde datum. + +### 2. Bug fix: TSS advance button (process-stepper.tsx) + +**Current behavior:** The `AdvanceButton` for `diagnose_erhalten → tss_beantragt` only updates `nutzer.aktueller_schritt`. It never sets `nutzer.tss_beantragt` or `nutzer.tss_beantragt_datum`. + +**Fix:** Replace the generic `AdvanceButton` for this specific transition with a custom handler: + +```sql +UPDATE nutzer SET + aktueller_schritt = 'tss_beantragt', + tss_beantragt = TRUE, + tss_beantragt_datum = CURRENT_DATE, + aktualisiert_am = NOW() +WHERE id = 1 +``` + +The `StepAction` switch case for `diagnose_erhalten` gets an inline button instead of the generic `AdvanceButton`. + +### 3. Scenario module (new file) + +**File:** `src/features/einstellungen/scenarios.ts` + +**Exports:** `seedToStep(step: ProzessSchritt)` + +**Behavior:** Clears all data except `nutzer`, then builds state cumulatively based on the target step: + +| Target step | State seeded | +|-------------|-------------| +| `neu` | Reset nutzer to `aktueller_schritt = 'neu'`, all flags false, clear therapists/contacts/sprechstunden | +| `diagnose_erhalten` | 1 therapist + 1 sprechstunde with dringlichkeitscode=true, nutzer flags set accordingly | +| `tss_beantragt` | Above + `nutzer.tss_beantragt = true`, `nutzer.tss_beantragt_datum` set | +| `eigensuche` | Above + 20 therapists with mixed contact attempts | +| `antrag_gestellt` | Above + ensures ≥5 absagen/keine_antwort contacts for checklist item 4 | + +**Mock data constants** (MOCK_VORNAMEN, MOCK_NACHNAMEN, MOCK_STAEDTE, etc.) move here from `kontakte/hooks.ts`. + +### 4. Settings UI (settings-page.tsx) + +Replace the current dev mode section (single "Testdaten einfügen" button) with a dropdown + button: + +- **Label:** "Szenario laden" +- **Description:** "App-Zustand für einen bestimmten Prozessschritt laden" +- **Dropdown options:** + - Schritt 1 — Erstgespräch + - Schritt 2 — Diagnose erhalten + - Schritt 3 — TSS kontaktiert + - Schritt 4 — Eigensuche + - Schritt 5 — Antrag gestellt +- **Button:** "Laden" +- **Feedback:** Brief "Fertig" text after seeding (same pattern as current) + +### 5. Cleanup in kontakte/hooks.ts + +- Delete `seedMockData()` function +- Delete all `MOCK_*` constants (MOCK_VORNAMEN, MOCK_NACHNAMEN, MOCK_STAEDTE, MOCK_THERAPIEFORMEN, MOCK_ERGEBNISSE) +- Delete `daysAgoISO()` helper +- `deleteAllData()` stays — it's user-facing and deletes the nutzer row (full reset to onboarding) + +## Out of scope + +- **Antrag checklist "Absagenliste exportiert"** — stays hardcoded to `false`. Tracking PDF export clicks is a separate feature. The checklist will show 4/5 at `antrag_gestellt`. + +## Files changed + +- **Modify:** `src/features/prozess/components/process-stepper.tsx` — fix SprechstundeForm and TSS advance button +- **Create:** `src/features/einstellungen/scenarios.ts` — step-wise seed logic + mock constants +- **Modify:** `src/features/einstellungen/components/settings-page.tsx` — dropdown UI replacing single button +- **Modify:** `src/features/kontakte/hooks.ts` — remove seedMockData, mock constants, daysAgoISO