Commit Graph
202 Commits
Author SHA1 Message Date
Mao NakamotoandClaude Fable 5 de9db2f60d feat(zeiterfassung): Saldo ledger, monthly reminders, one-click submit — SMALL-Time retirement phase 1
The accounting layer the legacy SMALL-Time punch clock had and we lacked:

- migration 136: employment_periods (effective-dated Pensum in weekly
  minutes, seeded from contract_hours), vacation_entitlements (per
  person-year + carryover «Übertrag F»), team_profiles opening balance
  («Übertrag T») + zeiterfassung_reminder_day
- src/config/holidays.ts: Kanton-ZH public holidays SSOT (fixed +
  Easter-derived, deterministic — no yearly maintenance)
- lib/team/saldo.ts: pure Zeitsaldo engine — saldo is DERIVED, never
  typed: opening + Σ(Ist − Soll). Soll from employment periods spread
  over scheduled weekdays; holidays reduce Soll (no manual Feiertag
  rows, double-count guard); paid absences fulfil Soll, unpaid don't.
  10 tests incl. an exact reproduction of the legacy tool's −56h July
  example and a mid-year Pensum change
- lib/services/saldo.ts + GET /api/timecards/saldo (own; ?user_id= for
  approvers) — Feriensaldo defaults to 20 days pro-rated by Pensum when
  HR hasn't set an entitlement (exactly the legacy 60% → 12 Tage rule)
- SaldoStrip on /admin/zeiterfassung + compact variant on the team
  profile tab: Zeitsaldo, Feriensaldo, month Ist/Soll, plus a hint when
  the schedule template disagrees with the Pensum
- monthly reminder: pick a day (ReminderSetting), daily cron
  /api/cron/timecard-reminders nudges in-app+mail if the month is not
  submitted — verified end-to-end (approved cards correctly skipped)
- one-click «Füllen & einreichen» on an empty draft month (also the
  reminder's landing action)
- all new UI strings in 8 locales

Verified in the browser against live data: +27h36 saldo = 90h Ist vs
62h24 Soll-to-date at 24h/week, hand-checked.

Phase 2 (tracked): vacation-flow unification, monthly close snapshot +
PDF (payroll + social-worker report), HR proxy entry, opening-balance
UI, SMALL-Time cutover.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 16:07:57 +02:00
e92df22be1 fix(protocols): chunked transcription for long recordings + one retry pipeline (#218)
The 2026-07-16 follow-up incident: after migration 134 unblocked the INSERT,
a 63 MB meeting recording still failed with "Fehler bei der Audio-Verarbeitung".
Root cause: Groq Whisper caps uploads at ~25 MB and the local faster-whisper
fallback only exists in dev — so any recording longer than ~45 minutes could
NEVER transcribe on prod, while the upload UI advertised 250 MB. On top of
that, the detail-page retry used the legacy /process-audio endpoint, which
collapsed the specific error into a generic message.

Transcription (root fix):
- src/lib/transcription/segment-audio.ts — ffmpeg transcodes big files to
  16 kHz mono MP3 and splits them into 15-minute segments (~5 MB each)
- transcribeAudio: <=24 MB goes to Groq directly; bigger files are segmented
  and transcribed chunk by chunk, text joined in playback order; local
  whisper stays as the dev fallback
- selfhost-deploy: idempotently installs ffmpeg on the prod box
- process-sources: an empty audio transcription only fails the request when
  audio was the sole source — typed notes / files still carry the meeting
- unit tests for provider selection incl. the chunked path

One pipeline (DRY):
- Detail-page retry (draft "Inhalt liefern" card + review "Erneut verarbeiten")
  now posts to the SAME /api/protocols/[id]/process-sources the create page
  uses — audio and/or text, same specific error messages
- Legacy /process and /process-audio routes and their tests deleted;
  /process-notes stays (direct JSON import without AI), /import-tasks stays
- ProtocolDraftInput reworked: one card, audio + text together, "Mit KI
  strukturieren" instead of "Schritt 2 starten" jargon
- Footer actions moved out of the notes-only block: a stuck draft can now be
  deleted instead of lingering forever

Prod verification:
- tests/e2e/prod-protocols-smoke.spec.ts + "Prod protocols smoke" workflow
  (workflow_dispatch): generates real German speech audio with espeak-ng,
  logs in as the staff E2E account, uploads on /admin/protocols/new, waits
  for transcription + AI structuring, asserts review state, deletes the
  protocol. Variants for the direct (<24 MB) and chunked (>24 MB) paths.


Claude-Session: https://claude.ai/code/session_01QXEBWjhBB9JYsgLSX4jNES

Co-authored-by: Georgy Butaev <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 12:38:24 +02:00
G 6dc60279e2 feat(intake): quality-control pipeline — verdicts, publish gates, buyer-facing test results, QR labels, mobile UX, Kivvi (#212)
Checklist pass/fail/n.a. verdicts with a failed pipeline state; QC publish gate on all three publish paths; buyer-visible test results + verified badge; QR device labels; Vier-Augen-Prinzip on final QA; mobile-first pipeline cards; Kivvi sync from both intake doors. E2E journey updated to the verdict API with a second seeded staff account for four-eyes sign-off.
2026-07-16 12:11:35 +02:00
GandClaude Fable 5 6bea23a407 feat(teams): team space — AI form assist, task/protocol connections, members-first UI (#216)
* feat(teams): invite members by email + seed Forschung & Entwicklung team

Team onboarding gets a full email-invite flow, unified on the existing
placeholder-claim mechanism (one path, no parallel invitation table):

- Invite by name + email on the team page (super admin): registered staff
  are added directly and notified; unknown addresses get a placeholder
  account with the membership plus a claim link (14d, single-use) by email
  (POST /api/admin/teams/[id]/invitations)
- Placeholder "Einladen" can now send the claim link by email (optional
  address field) instead of clipboard-only delivery
- Claim page prefills the email field from the delivery address
- Direct member-add notifies the person by email (self-join stays silent)
- New templates teamClaimInvite / teamMemberAdded (Swiss German, escaped)
- Migration 132 seeds the Forschung & Entwicklung team with Georgy as lead
- Docs: EMAILS.md trigger table gains the Teams rows

Tests: 18 new (templates + schemas); typecheck, lint, lint:umlauts clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(ci): repair inherited E2E breakage — seed columns + moved admin route

Both failures predate this branch (main's last five CI runs fail the same
two jobs):

- e2e-seed.ts still wrote technician_profiles.is_verified /
  verification_date, dropped in migration 122 (identity moved to
  user_profiles in 121). Seed now sets the verified flag on user_profiles,
  keeping the "verified technician" premise.
- inventory-routes.ts pointed at /admin/repairer-applications — the one
  hardcoded path in the list, which drifted when the section moved. Now
  uses ROUTES.admin.hrApplications (config-driven like every other row).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(db): recreate ensure_seller_profile() without dropped display_name

Migration 122 dropped seller_profiles.display_name but the trigger
function from 031 still inserted it, so the first listing insert of any
user without a seller_profiles row errored — surfaced by the E2E seed,
and a live bug for new P2P sellers. Migration 133 recreates the function
inserting only user_id (identity lives on user_profiles since 121).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(e2e): first() on assertions whose text legitimately renders twice

Timecard submit ("Zur Prüfung gesendet" in status banner + summary line),
tasks empty state, and blog body/excerpt all resolve to two elements,
tripping Playwright strict mode — timecard failed every retry, the other
two were flaky. Assert on .first(); either occurrence being visible is
what the journeys actually verify.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(timecards): race-safe draft creation + stale E2E heading assertion

Two concurrent first-hits of GET /api/timecards for the same user+period
both passed the existence check and raced the
UNIQUE(user_id, period_start, period_end) insert — the loser 500'd
("Zeitkarte konnte nicht geladen werden"). Insert now uses ON CONFLICT DO
NOTHING and serves the row the winner created.

The timecard journey also asserted a "Zeitkarten" heading on
/admin/zeiterfassung — that page's H1 is "Zeiterfassung" (the Zeitkarten
approval queue moved to its own page). Assert the real heading.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* feat(teams): AI form assist on team create/edit

The team-config form (/admin/teams/new) was one of the few creation
forms without the shared AIFormAssist bar. Standard two-step wiring:

- FORM_AI_REGISTRY entry 'team-config' — describe the team in a sentence
  and name/purpose/mail_folders/meeting_cadence/accent are filled; accent
  options derive from the teams config SSOT, no invented mail addresses
- AIFormAssist dropped into TeamFormClient (expanded on create, refine
  available on edit); AI-filled mail_folders array maps onto the form's
  newline-joined field, accent validated against the config enum
- Accent labels hoisted from the component into TEAM_ACCENT_LABELS in
  src/config/teams.ts (SSOT — form select and AI prompt share one list)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* feat(teams): team space — tasks + protocols connected to the team page

The team page becomes a working space by connecting existing systems
instead of adding new ones (goals, KPIs, focus, coverage already live
there):

- Migration 134: optional team_id on tasks + meeting_protocols
  (ON DELETE SET NULL, indexed) — org-wide records stay untouched
- Task form gains an optional Team select (create + edit); protocol
  form the same (options server-fed from listTeams)
- "Neue Aufgabe" / "Neues Protokoll" on the team page preselect the
  team via ?team= (validated against real teams before prefill)
- Team page shows two new panels: open tasks (due-first, assignee +
  priority) and recent protocols (status-badged), with empty states
- New team-space service (SoC: queries only); panels are pure server
  components reusing config label/color SSOTs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(teams): members first, one add/invite element below the list

The Mitglieder section led with two stacked forms before showing a
single member — backwards for a page you mostly read. Now the member
list comes first; below it sits ONE card: the staff picker row, and
for super admins a fold-out «Noch nicht registriert? Per E-Mail
einladen» containing the email invite (no second card, no chrome).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-16 11:33:50 +02:00
ec5ce6babc fix(protocols): drop drifted enum CHECKs blocking audio protocols + calmer create form (#214)
Creating a protocol from an audio recording failed on prod: migration 027b
used ADD COLUMN IF NOT EXISTS ... CHECK, which silently skips the CHECK when
the column already exists — so the stale input_method value list (without
'audio') survived and rejected every valid audio insert.

Migration 134 guarantees the input_method column exists and drops all CHECK
constraints on meeting_protocols + protocol_action_links by catalog lookup.
All of them are hand-synced enum lists already validated at the write
boundary via zod schemas derived from src/config/protocols.ts — same policy
as migration 110 (notifications). Verified by replaying both the fresh-from-
zero and the drifted-prod state in a throwaway Postgres 16.

Create form (/admin/protocols/new) noise reduction:
- Open-source fallback tools (CaptureAlternatives) move out of the middle of
  the hero card to a collapsed disclosure at the page bottom — reference
  material, not part of the flow.
- Hero hierarchy now matches usage: drop zone first, record button with its
  consent checkbox beside it, notes textarea last; the filler "oder / Datei
  hochladen ↓" spans are gone.
- Submit is a plain action row instead of a third card; the format/char-count
  meta line only renders once there is text.


Claude-Session: https://claude.ai/code/session_01QXEBWjhBB9JYsgLSX4jNES

Co-authored-by: Georgy Butaev <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 11:22:09 +02:00
GandClaude Fable 5 2499936262 feat(teams): invite members by email + seed Forschung & Entwicklung team (#210)
* feat(teams): invite members by email + seed Forschung & Entwicklung team

Team onboarding gets a full email-invite flow, unified on the existing
placeholder-claim mechanism (one path, no parallel invitation table):

- Invite by name + email on the team page (super admin): registered staff
  are added directly and notified; unknown addresses get a placeholder
  account with the membership plus a claim link (14d, single-use) by email
  (POST /api/admin/teams/[id]/invitations)
- Placeholder "Einladen" can now send the claim link by email (optional
  address field) instead of clipboard-only delivery
- Claim page prefills the email field from the delivery address
- Direct member-add notifies the person by email (self-join stays silent)
- New templates teamClaimInvite / teamMemberAdded (Swiss German, escaped)
- Migration 132 seeds the Forschung & Entwicklung team with Georgy as lead
- Docs: EMAILS.md trigger table gains the Teams rows

Tests: 18 new (templates + schemas); typecheck, lint, lint:umlauts clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(ci): repair inherited E2E breakage — seed columns + moved admin route

Both failures predate this branch (main's last five CI runs fail the same
two jobs):

- e2e-seed.ts still wrote technician_profiles.is_verified /
  verification_date, dropped in migration 122 (identity moved to
  user_profiles in 121). Seed now sets the verified flag on user_profiles,
  keeping the "verified technician" premise.
- inventory-routes.ts pointed at /admin/repairer-applications — the one
  hardcoded path in the list, which drifted when the section moved. Now
  uses ROUTES.admin.hrApplications (config-driven like every other row).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(db): recreate ensure_seller_profile() without dropped display_name

Migration 122 dropped seller_profiles.display_name but the trigger
function from 031 still inserted it, so the first listing insert of any
user without a seller_profiles row errored — surfaced by the E2E seed,
and a live bug for new P2P sellers. Migration 133 recreates the function
inserting only user_id (identity lives on user_profiles since 121).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(e2e): first() on assertions whose text legitimately renders twice

Timecard submit ("Zur Prüfung gesendet" in status banner + summary line),
tasks empty state, and blog body/excerpt all resolve to two elements,
tripping Playwright strict mode — timecard failed every retry, the other
two were flaky. Assert on .first(); either occurrence being visible is
what the journeys actually verify.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

* fix(timecards): race-safe draft creation + stale E2E heading assertion

Two concurrent first-hits of GET /api/timecards for the same user+period
both passed the existence check and raced the
UNIQUE(user_id, period_start, period_end) insert — the loser 500'd
("Zeitkarte konnte nicht geladen werden"). Insert now uses ON CONFLICT DO
NOTHING and serves the row the winner created.

The timecard journey also asserted a "Zeitkarten" heading on
/admin/zeiterfassung — that page's H1 is "Zeiterfassung" (the Zeitkarten
approval queue moved to its own page). Assert the real heading.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Akm86ZwqhiSM2BfdKH96cN

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-16 08:57:54 +02:00
Mao NakamotoandClaude Opus 4.8 3b1178ab69 refactor(teams): extract useAsyncAction hook (DRY) + David rename + example seed
- useAsyncAction: the run(key,fn){busy;error;refresh} pattern was copy-pasted
  across 8 team components. Extract one hook (SSOT); adopt it in the 3 new
  coordination components (Goals/Metrics/JoinButton).
- Placeholder Dana → David (Dani = Daniel; keep gender). Email + seed updated;
  stale "Platzhalter surname is the marker" comment corrected (email domain is
  the only marker now).
- scripts/db/seeds/team-coordination-examples.sql: example goals + KPIs on the
  Reparatur team so the hub isn't empty (idempotent; editable rows).

Verified: typecheck + lint (0 errors). Prod DB updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 19:15:58 +02:00
Mao NakamotoandClaude Opus 4.8 b06f1941d3 feat(teams): team page as coordination hub — goals + KPI metrics + self-join
Make each team page useful for coordination, and let any staff join/leave a
team in one click from the team page itself.

- Migration 131: team_goals (title/detail/status/target_label) + team_metrics
  (label/current/target/unit/higher_is_better, nullable source_key reserved for
  a future auto-compute path). goal status enum lives in src/config/teams.ts +
  zod — plain TEXT column, no CHECK (per CLAUDE.md §DB).
- Service in a NEW file team-coordination.ts (teams.ts was already ~385 lines —
  no god file); shared metricProgress() helper honours metric direction.
- API: /teams/[id]/goals[/[goalId]] + /metrics[/[metricId]], all withAdmin('teams')
  so any staff can maintain them (transparent, matches membership edits).
- UI: TeamGoalsSection (roadmap w/ config-driven status chips), TeamMetricsSection
  (KPI cards + progress bar), TeamJoinButton (self join/leave — the API already
  allowed it; this exposes it on the team page). Draft forms are module-level
  (react-hooks/static-components), statuses/labels/colours all from config.
- Team page also surfaces meeting cadence.

Verified: typecheck, lint (0 errors), test:i18n 7/7. Migration applied + recorded
on prod.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 18:42:33 +02:00
Mao NakamotoandClaude Opus 4.8 b5825da736 feat(teams): rock-legend placeholder names (recognizable first name + real surname)
Rename the 15 placeholders from "<First> Platzhalter" to "<First> <rock legend>"
(Vera Hendrix, Rezo Hetfield, …). First name still starts with the same letters
as the real teammate so who-is-who stays clear; the @placeholder.revamp-it.ch
email remains the systematic not-yet-claimed marker. Applied to prod via UPDATE.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 17:57:22 +02:00
Mao NakamotoandClaude Opus 4.8 dfac12e500 feat(teams): complete 8-team set + pseudonymised placeholder members
Migration 130 adds the 4 teams the Teamsliste has beyond 129's first four:
verkauf, lager, reparatur, and fundraising (seeded is_active=false — crossed
out on the source; kept for history, not deleted). mail_folders left empty
(source listed none for these) — fill via /admin/teams, never guess an address
onto the wrong team.

Seed (scripts/db/seeds/team-placeholders.sql, NOT a migration → never runs in
CI/fresh dev) creates 15 locked placeholder members + 30 memberships across all
8 teams. Placeholders are password_hash NULL (cannot log in until claimed),
surname "Platzhalter" + @placeholder.revamp-it.ch domain (findable/claimable
markers). Real people onboard later by claiming their row via a registration
link. Georgy is the only real account (georgy.butaev@revamp-it.ch), never
pseudonymised. Roles map the Teamsliste's Haupt/Vertretung → lead/deputy.

Applied + recorded on prod; verified all 8 teams read correctly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 17:39:59 +02:00
Mao NakamotoandClaude Opus 4.8 28e2359381 feat(teams): first-class Teams + many-to-many membership (Phase 1)
Replace the fictional team_profiles.department string with real named teams
(Orga, IT-Admin, Medien/Kommunikation, Laden). Each team owns Nextcloud mail
folders and has members with a role (lead/deputy/member); people belong to
MULTIPLE teams, so membership is a many-to-many join. left_at preserves
transfer history.

- Migration 129: teams + team_memberships (enums = plain TEXT, authority in
  src/config/teams.ts + zod per CLAUDE.md §DB; only structural invariant in SQL
  is the partial-unique of one LIVE membership per (team, person)). Seeds the 4
  teams + confirmed @revamp-it.ch accounts, guarded for from-zero CI replay.
- src/config/teams.ts — SSOT for team roles + membership enums
- src/db/schema/teams.ts, src/lib/schemas/teams.ts, src/lib/services/teams.ts
- /admin/teams CRUD + assignment board + MembershipManager (transfer via
  MoveMemberModal) + TeamFocusInput
- /admin/team/me + MemberTeamsCard/MemberBoardCard on the member view
- i18n keys for all locales

Verified: lint, typecheck, test:i18n (7/7) all green. Migration idempotent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 17:17:08 +02:00
Mao NakamotoandClaude Opus 4.8 2b444f29d4 feat(deliverables): render description as markdown on share page + general, name-free instructions
Share page now shows the deliverable description as formatted markdown (what it
is, how to view/download/embed/ask/give feedback) so any recipient can use it
without a login — not personalised to one person.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 10:56:49 +02:00
Mao NakamotoandClaude Opus 4.8 6e4db31c69 feat(presentations): real team photos on V3 (repair + support desk)
From PR-Fotos/Fotos-Feb26: a team member doing focused repair now sits beside
the 'grosses Team' slide (split layout — the team finally has a face), and the
Support-Desk photo (two people, the 'Support Desk' sign) replaces the generic
bench shot on the Beratung/Support slide.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 21:26:55 +02:00
Mao NakamotoandClaude Opus 4.8 b64709eada fix(feedback): unblock deck comments (CSRF) + make site feedback reliable
Presentation comments were dead in prod: the static decks are served outside
middleware, so a reader has no CSRF cookie and the POST always failed
'CSRF validation failed'. Exempt /api/presentations/comments from CSRF (like
the webhook endpoints) and compensate with per-IP rate limiting + the honeypot.

Site feedback widget (/api/suggestions) was email-only and silently lossy —
sendCustomEmail resolves {success:false} instead of throwing, so failed
delivery went unnoticed. Now:
- persists to site_suggestions (migration 127) — the reliable channel
- notifies super admins in-app (bell) per submission
- still emails the team, but CHECKS the result and logs failures
- new admin page /admin/feedback to browse, resolve, copy-as-prompt
- route test updated (13/13) for the new persistence/notify/auth side channels

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 17:56:42 +02:00
Mao NakamotoandClaude Opus 4.8 5fe8e02c64 feat(presentations): per-slide reader comments + admin collection
Readers of a shared deck can comment on any slide — signed in OR anonymous:
- New table presentation_comments (migration 126) + Drizzle schema.
- Public API /api/presentations/comments: GET (who-am-I for the form) +
  POST (anonymous allowed; signed-in identity taken from the session, not
  spoofable; honeypot for bots). Notifies super admins in-app per comment.
- Deck UI: a 'Kommentar' button on every slide (hidden in fullscreen/print/
  export) that posts feedback for the current slide.
- Admin /admin/presentations/feedback: comments grouped by deck -> slide with
  an 'Als Prompt kopieren' button (slide-keyed, paste-ready for the AI) and a
  resolve toggle. Feedback link + open-count badge on the Präsentationen page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 17:35:48 +02:00
Mao NakamotoandClaude Opus 4.8 a4da182541 feat(blog): auto-translate on publish + staff draft preview
Auto-translate (opt-in per post, default on):
- migration 124: blog_posts.auto_translate, blog_post_translations.is_machine.
- On publish (create or edit) with auto_translate on, missing locales are filled
  from the German base in the background (fire-and-forget, like syncToKivvi) via
  the shared fillMissingTranslations helper — missing-only, never overwrites a
  human tab. Editor gets an "auto-translate on publish" toggle.
- Machine rows are flagged is_machine; a human edit in the editor clears it. The
  editor tab shows an amber sparkle for unreviewed machine translations, and the
  public page shows an "automatisch übersetzt" note.

Staff draft preview:
- getDbPostForPreview fetches a post regardless of published state; the [slug]
  page renders drafts for logged-in staff (with an "Entwurf" banner) and 404s
  for everyone else. The editor's Vorschau link now works for drafts too — fixes
  "can't see what a draft will look like before publishing".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 16:05:17 +02:00
Mao NakamotoandClaude Opus 4.8 82463eabd4 feat(blog): no-git per-locale translations for DB posts + AI translate
Closes the last gap in "admins manage posts without git": DB-authored blog
posts can now be translated into every locale entirely in the editor.

- migration 123: blog_post_translations (base German in blog_posts, non-de
  overlay here; PK (post_id, locale), FK cascade). Locale validated at the
  write boundary (no SQL CHECK, per migration-110 policy).
- read overlay in blog-db.ts: getPostBySlug/getAllPosts take a locale and
  overlay the translation, falling back to the German base; getDbPostLocales
  feeds hreflang. seo_title/seo_description now drive generateMetadata.
- write: admin blog API accepts a translations[] array; syncPostTranslations
  (validated upsert + prune) reused by create + edit.
- editor: language tabs (BlogTranslationTabs) + locale-aware useBlogPostForm.
- scalable AI translation: POST /api/admin/blog/[id]/translate fills missing
  locales from the German base via the provider cascade (Groq→OpenRouter→
  Ollama), sequential with retry/backoff to respect the per-minute token
  limit; "Fehlende übersetzen" button in the editor.
- tests: schema, translation sync, AI translate service, blog-db overlay.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 14:45:05 +02:00
Mao NakamotoandClaude Opus 4.8 a44b787a84 fix(profiles): migration 122 drops lingering helper_profiles_v before column
Prod deploy aborted (safely — 2b stayed live) because a dead view,
helper_profiles_v, still referenced technician_profiles.is_verified. The view
was DROPped in migration 073 (its TS was removed, no reader), so it was already
absent in the from-zero replay — but it lingered on the prod DB (drift). Drop the
remnant at the top of 122; IF EXISTS keeps the clean replay a no-op. Confirmed on
prod: nothing depends on the view, and no other object depends on any dropped
column.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 07:27:55 +02:00
Mao NakamotoandClaude Opus 4.8 702b803633 feat(profiles): SSOT slice 3 — drop duplicated identity columns
Contract phase of the Profiles SSOT consolidation. 2a (sellers) and 2b
(technicians) moved every reader AND writer of public identity to user_profiles
and both are LIVE on prod, so the role-table duplicates are dead. Remove them.

- migration 122: drops seller_profiles.{display_name,avatar_url,bio,is_verified,
  verification_date} and technician_profiles.{is_verified,verification_date}
  (+ the two verified indexes). Idempotent; ordered after 121's backfill so the
  from-zero CI replay stays green (verified locally: 131 migrations apply clean,
  end state has identity only on user_profiles).
- Drizzle: identity columns removed from sellerProfiles / repairerProfiles.
- Kept: seller/technician canton, technician city + verification_documents,
  technician_reviews.is_verified (a review flag) — those are role facts, not
  identity.

user_profiles is now the sole owner of public identity + per-person verification.

DEPLOY NOTE: safe only because 2a/2b are already live — the migrate→activate
window has no build that still reads these columns.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 07:18:01 +02:00
Mao NakamotoandClaude Opus 4.8 ef4d3c6472 feat(profiles): SSOT slice 2a — seller reads+writes via user_profiles
Public seller identity (display_name/bio/avatar/is_verified) now resolves
from user_profiles everywhere, and the seller's own editor writes there —
so the duplicated seller_profiles columns have no live reader/writer left
(dropped in slice 3). Reads and the /me write ship together, so there is no
window where the public sees a stale name.

- sellerProfileCoreFields: identity fields sourced from userProfiles; every
  caller now leftJoins user_profiles (sellers/[id], sellers/me GET).
- /api/sellers/me PATCH: upserts identity into user_profiles, writes
  city/canton to seller_profiles, re-selects the joined row for the response
  (can't RETURNING across two tables).
- listings GET / [id] / favorites, checkout-listing, sellers/[id] layout:
  join user_profiles for display_name/bio/avatar/is_verified; city/rating
  stay on seller_profiles (storefront facts).
- members/[id]: is_verified + name/avatar from user_profiles SSOT.
- tests updated for the new join/write shapes (55 green).

City/canton intentionally untouched (service base / storefront ≠ identity).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-11 10:16:20 +02:00
Mao NakamotoandClaude Opus 4.8 2d8ac0b019 feat(profiles): SSOT slice 1 — user_profiles owns public identity
First of 3 slices consolidating duplicated public-identity fields
(display_name/avatar/bio/is_verified) that today live on seller_profiles
and technician_profiles and can disagree. Non-breaking expand+backfill:

- migration 121: add is_verified/verification_date to user_profiles;
  backfill display_name/avatar/bio/is_verified from the role tables
  (COALESCE-preserve any existing value; verified = OR across roles).
  Role-table columns kept in place — readers move in slice 2, columns
  drop in slice 3. Replay-validated against seeded deps (existing
  display_name preserved, verified merged, rows created).
- Drizzle: userProfiles.isVerified / verificationDate.
- new public-identity.ts: getPublicIdentityMap / publicIdentityColumns /
  resolveDisplayName — the read chokepoint slice 2 routes everything through.
- city/canton deliberately left on role tables (storefront / service base,
  not identity). Full rationale + slice plan in docs/PROFILES_SSOT_PLAN.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-11 09:52:22 +02:00
Mao NakamotoandClaude Opus 4.8 5b4dc37a4a feat(blog): make every post editable & deletable from admin (no git)
Staff can now manage git/file-authored posts from the admin UI without touching
the repo:
- 'Edit' imports the file post into blog_posts (DB wins on slug in the merged
  reader) and opens the normal editor.
- 'Delete' hides the slug via blog_hidden_slugs; public readers + the admin list
  skip it (the markdown stays in the repo as a harmless fallback).
- blog_posts gains a visibility column (public|unlisted); the DB reader + admin
  list now report it instead of hardcoding 'public'. (migration 120)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 09:47:21 +02:00
Mao NakamotoandClaude Opus 4.8 d3d7338231 feat(blog): comments — any logged-in user can comment
New blog_comments table (migration 119) keyed by post SLUG so it works for
both DB- and git/file-authored posts. Public GET; auth-gated POST (2–2000
chars); author or staff can delete. Comment thread + composer render on every
post page (login prompt when logged out). UI strings translated in all 8 locales.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 09:25:42 +02:00
Mao NakamotoandClaude Opus 4.8 ea5e717f53 feat(erfassung): structured storage-location picker (replaces free-text location)
When erfassing a product, staff now pick WHERE it physically is from a
runtime-addable list instead of typing free text — and can add a new location
inline without leaving the form.

- Migration 117: `storage_locations` table (name, kind, holder_user_id for
  member-possession, is_active) seeded with Hauptlager/Laden/Nebenlager +
  `inventory_items.storage_location_id` FK. Free-text `location` kept for compat.
- Config SSOT `config/erfassung/storage-locations.ts`: 5 kinds (main_storage,
  shop, secondary_storage, member_possession, other) + DE labels + seeds.
- API `/api/admin/storage-locations` GET (active list) + POST (add).
- `<StorageLocationSelect>`: fetch + Select + inline "+ Standort" add, wired
  into ProductDimensionFields; threaded through the erfassung zod schemas →
  formDataToPayload → create-product so it persists.
- i18n: components.erfassung.storageLocation (de + en).

Distinct from the public `locations` table (venues). One location per product.
0 tsc errors, lint clean, umlauts + i18n-parity clean, 342 erfassung/schema/
config tests green. Built in an isolated worktree (a parallel session held the
main tree with in-progress blog work).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 18:51:39 +02:00
Mao NakamotoandClaude Opus 4.8 6bd1f9ae8f refactor(repairer): remove orphaned pro-repairer application/certification flow
The "professional repairer" application flow let users apply to become vetted
pro technicians pending admin approval — but the professional tier was never
assigned to any profile, so the whole pipeline (apply → review → approve/reject,
certification + document verification) produced only dead pending/rejected rows
with no downstream effect. Removed entirely.

Deleted (36 files): /api/repairer/apply, all /api/admin/repairer-applications
routes, /api/admin/documents + /api/admin/certifications routes, the
/admin/repairer-applications page, the 9-file review-UI component dir, the
repairer email templates, and the now-dead certification-status.ts +
document-status.ts config.

Shared-file edits:
- schema: dropped the `repairerApplications` (technician_applications) table
- TABLE_NAMES: removed REPAIRER_APPLICATIONS + the 4 cert/doc tables that the
  deleted routes queried (those 4 never had a migration — they never existed)
- dashboard: removed the repairer-application count + inline action
  (getDashboardStats / buildActionItems / types / InlineActionButton)
- actions.ts: removed approveRepairerApplicationAction
- config/permissions/nav: removed the `repairer-applications` section,
  permission alias, and breadcrumb
- IT-Hilfe admin: the empty-state CTAs (which pointed at the deleted review
  page) now point at the technician directory /it-hilfe/techniker; DE copy
  updated to reflect that technicians self-register
- email: removed the repairer + adminNewRepairerApplication templates/exports
- config/repairer-status: removed REPAIRER_APPLICATION_STATUS(+_LABELS)

Migration 116 drops technician_applications (CASCADE).

KEPT (the live community-technician / IT-Hilfe flow): repairer_profiles
(profile_tier='community'), technician_services/availability/reviews,
getActiveTechnicianProfileId, all /api/it-hilfe/* + /it-hilfe/* pages,
TechnicianProfileSchema, the dashboard totalTechnicians count.

Verified: 0 dangling references, 0 typecheck errors, lint clean, 131 test
suites / 3082 tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 18:06:15 +02:00
Mao NakamotoandClaude Opus 4.8 f1d552f62a feat(promo): discount/gift-code foundation — schema + engine + seeds
Phase 1 slice 1 of the promo/gift-code system. Adds the redeemable-code
rail without wiring it into checkout yet (that's the next slice):

- Migration 115: promo_codes (typed: percent | fixed | gift_card, with
  scope, usage/per-user limits, validity window, gift-card balance) +
  promo_code_redemptions ledger. Type/scope are app enums, not DB CHECK
  lists (repo rule); only true invariants are CHECK-constrained. Seeds
  revamp100 (CHF 100 off) + revamp100p (100% off). Replays cleanly +
  idempotent (verified in a throwaway pg16).
- Pure discount engine (src/config/promo-codes.ts, 9 unit tests): caps
  fixed/gift-card at the order total (never negative), percent floors,
  enforces scope/min-order/expiry/limits.
- Redemption service (validate → compute; record consumes atomically,
  decrementing gift-card balance under a tx so limited codes can't
  overspend).

Distinct from the referral `coupons` table (per-user auto-rewards).
Next: admin issuance UI + checkout redemption (incl. 100%-off →
skip-gateway) across marketplace/workshop/appointment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:07:33 +02:00
Mao NakamotoandCursor 9aa982de60 feat(marketplace): add listing Q&A and buy CTA
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 19:36:11 +02:00
Mao Nakamoto ca322b00e3 ci(e2e): fix seeded journey drift 2026-07-04 13:04:02 +02:00
Mao Nakamoto 22117c0622 ci(e2e): add seeded local journey environment 2026-07-03 22:06:09 +02:00
Mao Nakamoto afe305d56c chore(db): retire dead medusa table and persist login lockouts 2026-07-03 21:48:44 +02:00
Mao NakamotoandClaude Fable 5 03fd3404f6 fix(ci): stop running mutating E2E journeys against production
The dual-persona job ran 13 journey specs (create/submit/approve real rows)
against prod, where fixture data doesn't exist — the service-appointment
journey needs the user persona to BE a technician and has been the standing
red. Prod keeps the read-only route inventory; the journeys move to the
seeded ephemeral e2e-local CI job (upcoming commit).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 20:46:43 +02:00
Mao NakamotoandClaude Fable 5 321c7269f1 chore(db): drop notifications type CHECK (110) + migration discipline policy
- 110: notifications_type_check dropped — recreated five times (039/040/069/
  093/108), caused two silent-insert-failure incidents; writers are exclusively
  internal services using NOTIFICATION_TYPES constants. Config + compiler are
  the validator; DB CHECKs stay reserved for true invariants.
- CLAUDE.md: schema changes only via migrations (drizzle-kit push forbidden),
  app-enum policy, local-replay-before-push rule
- npm run db:migrate → scripts/db/run-migration.sh
- delete scripts/deploy.sh + migrate-to-production.sh (pre-Hetzner relics
  invoking nonexistent migrate.js / docker-compose.prod machinery) + stale
  COMMANDS.md rows

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 20:20:08 +02:00
Mao NakamotoandClaude Fable 5 0984836dc8 chore(db): baseline the ten push-only tables (109)
Same disease as reviews/101b: created on prod via drizzle-kit push, present in
no migration — from-scratch replays lacked them. Two are actively written
(user_lockouts by the auth rate-limiter, activity_feed by logActivity);
location_approvals only survived CI replay because 085 guards on to_regclass.
Exact prod DDL, fully idempotent; re-attaches the 085 immutability trigger
that fresh replays skipped. Verified: full 96-migration local replay clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 20:15:55 +02:00
Mao NakamotoandClaude Fable 5 23afa14413 chore(admin): legacy cleanup + repair the silently-red CI pipeline
Legacy cleanup (access control verified — no prod user holds legacy keys):
- Delete /admin/products (+components/hooks/APIs with zero live callers),
  /admin/analytics (+orphaned service), /admin/timecards redirect stub
- Factsheet print view is a LIVE feature, not legacy: re-homed to
  /admin/erfassung/[id]/factsheet, "Factsheet drucken" restored on the
  erfassung success screen (routes.ts erfassungFactsheet)
- sections.ts: drop 'analytics' + duplicate 'finances' (finanzen stays);
  'timecards' + 'products' kept as live permission keys with repointed paths
- permissions.ts: remove migrateOldRole + dead aliases (finances→finanzen,
  it-hilfe→it-hilfe-admin); design aliases kept and documented
- TIME_OFF_REVIEW notifications now deep-link /admin/team/approvals

CI Pipeline (red since ≥1.7. while deploys stayed green):
- 101b_reviews_table_baseline.sql: `reviews` was Drizzle-pushed, never
  migrated — from-scratch replay died at 102. Baseline = exact prod DDL,
  idempotent, trigger guarded; full 94-migration replay verified locally
- 108_notification_types_membership_content.sql: CHECK constraint gains
  membership_payment_recorded + content_submission_status (drops orphaned
  membership_approved)
- /admin/workshops/proposals: quick action, routes.ts, /admin/workshops/new
  and proposal emails all deep-link an index that never existed → redirect
  stub to /admin/workshops
- E2E accounts recreated on prod (lost in Neon cutover) + AUTH_TEST_*
  secrets rotated; login lockout clears with this deploy's restart

Also: approvals hero singular fix ("1 Inhalt wartet").

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 19:31:25 +02:00
GandClaude Opus 4.8 5bfa69a0e6 fix: profile save validation (null fields) + timecard submit (DB constraints) + submit UX (#197)
Three user-reported issues:

1. **Profile "Validierungsfehler" on save.** GET /api/user/profile returns `null`
   for empty columns, but UpdateProfileSchema only accepted `string|undefined`, so
   loading a sparse profile and clicking Save failed validation on ~18 null fields.
   Schema fields are now `.nullish()` (null = empty) — the API accepts what it returns.

2. **Timecards with leave never submitted / never reached approvers (migration 107).**
   The timecard_entries CHECK constraints (migration 067) predated the config's Swiss
   absence categories (ferien/krank/unfall/feiertag/militaer/unbezahlt) and 0-minute
   unpaid markers, so ANY card containing a leave entry failed to INSERT → submit
   rolled back → status never became 'submitted' → the approvals queue was always
   empty, even for a superadmin. Migration realigns the constraints with the config
   SSOT (category list + duration_minutes >= 0). Must reach the prod Hetzner DB.

3. **Submit far from fill controls.** Save/Einreichen lived only in the top header
   while fill-from-plan + leave buttons are mid-page. Added a sticky bottom action
   bar so submit is always one tap away after filling.

typecheck clean.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 18:28:17 +02:00
GandClaude Opus 4.8 0c10de727b fix(db): ensure workshop_instances.current_participants exists (migration 106) (#192)
Found during P1 E2E testing of the paid-workshop flow. The paid-registration path
and the payment webhook read/increment `workshop_instances.current_participants`
for capacity checks, but that column was created by the legacy cms-api migration
system and is NOT in any scripts/db/migrations/ file — so a migration-built DB
(including prod) can lack it, which would 500 the paid-registration INSERT the
moment Payrexx goes live. (The dev DB was indeed missing it.)

Idempotent: ADD COLUMN IF NOT EXISTS + backfill from confirmed registrations.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:19:34 +02:00
GandClaude Opus 4.8 0a01a8727e fix(payments): make Payrexx truly plug-and-play (webhook signature, capture, partial-config guard) (#191)
Audit of the Payrexx integration found gaps that would break live payments the
moment real credentials are added. Closes them so go-live is config-only:

G1 (critical) — webhook signature header. The handler read `payrexx-signature`,
but Payrexx signs with `X-Webhook-Signature` (lowercase-hex SHA-256 HMAC of the
raw body, key as UTF-8 — which the code already computes correctly). With the
wrong header every live webhook was rejected (fail-closed) → customers charged
but orders never advance. One-line header fix.

G2 — capture for workshops/appointments. Gateways only RESERVE funds (authorize);
capture was wired only for marketplace. Non-escrow workshop/appointment payments
were authorized but never captured → the hold expires (~7 days) and the money is
never collected. The webhook now captures non-escrow generic payments immediately
on the reserved event (after the state commit, with loud logging on failure so a
user is never locked out of what they paid for). Escrow payments stay held.

G3 — escrow auto-release. The old `scripts/auto-release-escrow.js` was dead
frankenstein code (Stripe + retired Neon DB_* vars) — deleted. Replaced with a
real `GET /api/cron/release-escrow` that captures any escrow still held past its
deadline (Payrexx), + a `revampit-cron@release-escrow.timer` (daily 04:00). Tested.

G4 — partial-config guard. `isPayrexxConfigured()` ignores the webhook secret, so
a config with INSTANCE+SECRET but no WEBHOOK_SECRET silently charges customers
while rejecting every webhook. `createGateway` now logs a loud error in that exact
state (`isPayrexxPartiallyConfigured()`).

Also: `reservation` now sent as the documented `1` (the string "true" is coerced
to 0 by Payrexx's PHP backend → reservation silently disabled); removed dead
`getBaseUrl()`; rewrote docs/operations/PAYREXX_SETUP.md as the precise
plug-and-play go-live checklist.

Verified live behavior unchanged in mock mode; typecheck + lint + umlauts clean;
full suite 530/7688 green.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 15:52:58 +02:00
GandClaude Opus 4.8 f949e3fca4 ci: replace mutating prod E2E smoke with a read-only post-deploy smoke (#179)
The "Dual-persona inventory smoke" job had failed on every recent deploy — it
logs in as butaeff@gmail.com (a test account purged this session) and runs 14
journeys, several of which MUTATE production (it-hilfe/marketplace/workshops),
re-polluting prod with exactly the E2E data we cleaned. A perpetually-red,
prod-polluting check provides no signal.

Replace it with scripts/post-deploy-smoke.sh: read-only, no login, no mutation —
asserts the key public pages render (200) and the DB-backed public APIs return
"success":true (technicians, listings, workshops, services, stats, health). This
exercises the real queries (incl. the just-renamed technician_profiles), catching
a broken deploy/schema mismatch the page-render gate alone might miss. Fast
(curl-only; drops the Node/Playwright install), deterministic, 5-min timeout.

The heavier authenticated dual-persona journeys remain available for deliberate
runs via `npm run test:e2e:inventory:prod` (now requires an explicit real
AUTH_TEST_USER_EMAIL — the hardcoded purged-account default was removed).

Verified: the new smoke passes all 13 checks against prod.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 02:50:39 +02:00
GandClaude Opus 4.8 0447aa76bb fix(db): drop empty orphan technician_profiles before rename (migration 105) (#177)
The first deploy of migration 105 failed: prod has an empty orphan
`technician_profiles` table (created by 002b-simplified-auth, never adopted —
live data is in repairer_profiles), so the rename errored "relation already
exists". The page-render gate aborted cleanly (prod stayed on the prior release;
the failed migration rolled back atomically, never recorded).

Fix: DROP TABLE IF EXISTS technician_profiles (0 rows, no inbound FKs) before the
renames. Verified on prod with BEGIN…ROLLBACK — renames apply cleanly.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 02:01:08 +02:00
GandClaude Opus 4.8 64eef9b3d3 refactor(db): rename repairer_* tables to technician_* (debt #1) (#176)
"Repairer" and "technician" are the same concept; the API/service layer already
uses "technician" (/api/technicians SSOT, technician-service) but the DB tables
still carried the old name. This renames the tables so the schema matches.

- Migration 105: ALTER TABLE repairer_{profiles,services,availability,reviews,
  applications} RENAME TO technician_*. Postgres carries indexes + inbound FKs
  automatically (views/FKs track by OID). Idempotent (IF EXISTS).
- Drizzle pgTable() names + TABLE_NAMES values updated in lockstep, so every
  query (Drizzle + sql.raw(TABLE_NAMES.*)) targets the new names.

Scope (deliberately kept to bound risk — all separately riskier):
- the `repairer_id` / `repairer_profile_id` COLUMN names (data/SQL churn),
- the `'repairer'` user-role VALUE (stored data + every role check),
- the JS identifiers `repairerProfiles`/`REPAIRER_PROFILES` (cosmetic, internal,
  tsc-guarded — a follow-up cosmetic pass).
No production code hardcodes the table names outside TABLE_NAMES/Drizzle (verified
by grep), so there is no un-tsc-guarded raw-SQL risk.

typecheck + lint + umlauts clean; full suite identical 7-suite baseline failures,
zero new. Migration auto-applies after 104 on deploy.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 01:51:17 +02:00
GandClaude Opus 4.8 a69a3c22d7 refactor(profiles): nullable repairer contact + drop dead seller columns (debt #5 phase 4) (#175)
Phase 4, re-scoped after a per-field write-site audit found NO mirror duplication
— the role-profile contact/bio/avatar fields hold legitimately-distinct business
data (entered via separate forms), so the original "consolidate into user_profiles"
idea was dropped as contraindicated. Only the dead/placeholder columns are cleaned:

- Migration 104: repairer_profiles.phone/address NOT NULL → nullable; normalize
  the '' placeholders (self-service community techs, who never enter business
  contact) to NULL. Drop the dead seller_profiles.phone/address/postal_code
  columns (never written by any code path; the seller form only collects city).
- Schema: drop .notNull() on repairer phone/address; remove the seller columns.
- technician-service.upsertTechnicianProfile no longer writes the '' placeholders.

No readers of the dropped seller columns. typecheck + lint clean; full suite zero
new failures vs baseline. Docs: ARCHITECTURE_DEBT #5 Phase 4 (re-scoped, done).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 01:33:33 +02:00
GandClaude Opus 4.8 bf28d7a8f7 chore(ops): record E2E test org-content + account purge script (#168)
Companion to purge-demo-content.sql. Records the one-time prod cleanup (already
applied) that truncated E2E org content (blog/jobs/workshops/decisions/protocols/
tasks — all "E2E …" titled) and deleted all ~53 test accounts, keeping only the
two real staff users (georgy.butaev@, shop@), georgy's real membership
application, and the 3 physical locations. Prod is now a clean slate.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 21:31:29 +02:00
GandClaude Opus 4.8 f40453ddce fix(technicians): kill fabricated stats (SSOT), show avatars; purge demo data (#167)
The public technician profile showed fabricated data — "George" (a seeded test
account) with 80 reviews / 80 jobs / 5.0★ / verified / professional but ZERO
backing review rows. Root cause: aggregate columns were seeded with fake numbers
and `recomputeTechnicianAggregate` only updated technicians that HAD reviews
(inner join), so a 0-review tech kept stale/seeded values forever.

- recomputeTechnicianAggregate now LEFT JOINs a base row + COALESCE, so a
  technician with no published reviews is reset to 0/0.0 — fake aggregates can
  no longer survive a recompute.
- Technician profile now shows the real avatar (user_profiles.avatar_url, joined
  in getTechnicianById) with the initial-letter fallback. Avatar upload already
  works at /dashboard/profile → /api/uploads → Cloudflare R2 (storage was never
  missing — it's R2, verified live).
- scripts/ops/purge-demo-content.sql: the one-time prod cleanup (already applied)
  that TRUNCATEd the E2E/demo content (159 listings, 150 IT-Hilfe requests, 82
  appointments, 75 erfassung items, reviews, conversations) + removed the
  fabricated technician profiles, keeping all user accounts and org tables.

The profile's stats render was already guarded (>0), so with truthful data a
no-review technician simply shows no rating/jobs line.

typecheck + lint clean; full suite zero new failures vs baseline.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 21:02:37 +02:00
GandClaude Opus 4.8 1824bc83fd chore(marketplace): remove legacy marketplace_listings table + shop API/tab (#166)
`marketplace_listings` (RevampIT internal-shop table) and the /api/shop/inventory
routes were superseded by the unified `listings` table (RevampIT stock carries
is_revampit=true, published via publishRevampitListing). The table was dead for
writes (orphan rows only). Removed end-to-end:

- Repointed the 4 remaining readers off marketplace_listings to `listings`:
  - /api/stats/community  -> count active `listings`
  - /api/stats/impact     -> drop the separate shop-sold count, which DOUBLE-COUNTED
    RevampIT sold items (already present in `listings` via is_revampit). Bugfix.
  - /api/admin/search-index -> recent `listings`
  - /api/user/donations   -> derive the "listed" stage from inventory_items.marketplace_status
    (no marketplace_listings join); sold_at from inventory_items.updated_at.
- Removed the admin "Shop Produkte" tab: deleted /api/shop/inventory[/[id]] routes,
  useShopProducts hook, ShopProductsTable, ProductTabSwitcher, and the orphaned
  inventory-service (getInventoryProducts/getInventoryProductByUuid). Collapsed
  ProductManagement to the single Erfassung-inventory view; dropped the now-dead
  unpublish flow. /admin/products still works (inventory view + erfassung return-to).
- Schema/config: removed the marketplaceListings Drizzle table + MARKETPLACE_LISTINGS
  from TABLE_NAMES; archived the one-time backfill script.
- Migration 103 drops the table (must reach the Hetzner prod DB). No FK references it.
- Docs: .claude/CLAUDE.md + ARCHITECTURE_DEBT updated (storefront unified).

The /shop/* pages stay as redirects to /marketplace for legacy URLs.

typecheck + lint clean; full suite zero new failures vs baseline.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 20:03:33 +02:00
Mao NakamotoandClaude Opus 4.8 6c78580576 refactor(reviews): unify technician ratings into one source (#2)
Three stores held technician ratings but only `reviews` fed the displayed
aggregate, so service-appointment ratings (inline `customer_rating`) and the
legacy `repairer_reviews` table never counted, and the aggregate itself had an
overwrite bug (the IT-Hilfe and repairer recomputes each set only their own
slice). Now `reviews` is the single source:

- Service-appointment "rate" mirrors into `reviews` via createReview
  (target_type=repairer, booking_id=appointment) so it feeds the aggregate.
- New recomputeTechnicianAggregate() computes repairer_profiles.average_rating /
  total_reviews from ALL of a technician's reviews — IT-Hilfe (via accepted
  offer) + repairer (incl. mirrored appointment ratings) combined — replacing the
  two slice-specific updaters that overwrote each other. Verified end-to-end
  (IT-Hilfe 5 + repairer 3 → 4.00, count 2).
- Migration 102 backfills history from the inline ratings + repairer_reviews into
  `reviews` (idempotent), then recomputes every technician's aggregate. Legacy
  columns/table left in place (deprecated) for a later contract step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 14:58:05 +02:00
Mao NakamotoandClaude Opus 4.8 a12034dd0d feat(it-hilfe): structured compensation on offers (record amount, not free text)
Offers carried only a free-text proposed_compensation ("CHF 40", "nach Absprache")
— unqueryable/unverifiable. Add a structured proposed_amount_cents (migration 101)
captured via a CHF field in the offer form, surfaced in the offers list, and
returned by the offers/my-offers APIs. The accepted offer's amount is now the
recorded agreed compensation (money may still settle off-platform for the
solidarity model; this records the figure). Labels added in all 8 locales.

Also fixes the offers-route test: the earlier A2 change wrapped the offer write +
count bump in db.transaction(), which the test's db mock didn't provide — added
transaction() to the mock (tx reuses the same builders) so the suite is green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 10:56:44 +02:00
Mao NakamotoandClaude Opus 4.8 a64fc52ba6 fix(it-hilfe): unblock community-tech matching + fix offer_count/SSOT bugs
- A1 (critical): the new-request match fan-out was gated on isVerified=true, so
  self-serve COMMUNITY technicians (the persona this feature targets, default
  is_verified=false with no self-serve verification) never got notified — the
  discovery loop silently failed for them. Notify all ACTIVE skill-matched techs;
  verified stays a trust badge, not a notification gate.
- A2: offer_count had two writers (DB trigger from migration 090 + the API),
  double-counting every fresh offer. Migration 100 drops the trigger fn CASCADE
  (app is now the sole writer; it handles insert/resurrect/withdraw) and
  reconciles existing counts; the offers POST now wraps the offer write + count
  bump in one transaction. Also fixes dev/prod parity (dev push has no triggers).
- A3: onboarding checklist linked to the non-existent /dashboard/repairer (404)
  → /dashboard/techniker.
- A4: repairer_profiles.profile_tier defaulted to 'professional' (opposite of the
  self-serve community model) → default 'community' (migration + schema).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 08:38:06 +02:00
Mao NakamotoandClaude Opus 4.8 4cd02c10a1 feat(i18n): complete es/it/ja/ko/ru/fr translations + staleness detection
Fills the ~3,500 previously-untranslated keys across the six non-DE locales
(es/it/ja/ko/ru fully; fr completed) — the gaps that made pages render in mixed
German. ICU placeholders and plural structures preserved (verified: zero
placeholder mismatches per locale); brand/product names kept verbatim; array
shapes unchanged (array-parity gate green); all translated pages render 200.

Adds a staleness detector (scripts/i18n-stale.mjs + messages/_source-baseline.json):
records a hash of the DE source each translation was made from, and flags
translations whose DE source later changed — catching the "locale shows the old
copy" class that nothing previously detected (e.g. the stale RU homepage CTA).
Workflow: edit DE → `npm run i18n:stale` lists what drifted → re-translate →
`npm run i18n:stale-update <locale>`. Wired into `npm run compliance`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 06:46:52 +02:00
Mao NakamotoandClaude Opus 4.8 4f0455ba7a fix(i18n): remove stale hardcoded email from homepage CTA (6 locales)
home.finalCta.note in fr/es/it/ja/ko/ru still held an OLD version of the note
with a hardcoded, wrong email ("…napišite nam — info@revamp-it.ch"), while DE
was rewritten to "Geräte spenden bleibt möglich unter Mitmachen." The key wasn't
missing (so DE fallback never kicked in) — it had drifted. Updated all six to the
current meaning. Org contact data (the real address is empfang@revamp-it.ch in
org.ts) must never be baked into a translated string.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 20:47:12 +02:00
Mao NakamotoandClaude Opus 4.8 5801a38b23 refactor(services): dedupe the 3 bespoke services to a single source
hardware-recycling, linux-open-source and web-design-development were each
defined three times — a bespoke static page (the only one that renders, since
literal route segments shadow the [service] dynamic route), a service_types DB
row, and a servicePresentation entry. The DB row + presentation entry were dead:
getAllServiceSlugs() generated permanently-shadowed [service] routes for them,
and editing them changed nothing visible (a content trap).

- Migration 099 soft-deactivates the 3 service_types rows (is_active=false).
  Deactivate, not DELETE: service_appointments cascades on delete, so this
  preserves history, is reversible, and drops them from getAllServiceSlugsFromDb
  (which filters is_active=true).
- Removed the 3 servicePresentation entries (and now-dangling icon imports), so
  they no longer feed getAllServiceSlugs either.
- Dropped the misleading `slug` on linuxOpenSource in SERVICE_CONFIGS — it
  advertised online booking that the static page never offered.

The 3 services now live exactly once (their static page). Template services
(computer-repair-upgrades, data-recovery-transfer) are untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 19:48:41 +02:00