Commit Graph
140 Commits
Author SHA1 Message Date
Cato 892b870d66 Let the owner Gmail addresses administer evig
Admin is no longer a Revamp mailbox. butaeff@gmail.com and butai@gmail.com
join the lockout floor; the current Revamp login stays so that account
is not locked out. A verified floor address can open /admin even before
the staff flag is set.

Einstellungen can change the login address (code sent to the new inbox,
and a bootstrap owner keeps admin on the new address) and the password.
Anyone signed in can ask for admin. An existing admin confirms full
admin or everyday staff from the same screen.
2026-10-14 07:54:16 -07:00
CatoandClaude Fable 5.1 bbd25803b6 feat(auth): "Sign in with OrangeCat" beside the password login; connect from the profile (#523)
* feat(auth): "Sign in with OrangeCat" beside the password login; connect from the profile

Step D8 of orangecat ADR-0009 ("One account for every door"). evig keeps its
own accounts — staff grants, orders and memberships live here — and lets an
account BE an OrangeCat account by carrying the actor id.

- /auth/login: "Mit OrangeCat anmelden" beside the password form, shown only
  when Auth.js actually mounted the provider (the form asks /api/auth/providers),
  so the button can never be a dead end.
- users.orangecat_actor_id (migration 141, unique): the ONLY cross-product
  key. Never email — OrangeCat's password sign-up does not verify the address,
  so an email match would let anyone who registers the victim's address there
  walk in here. src/lib/auth/orangecat.ts holds the rules, pure and tested:
  a linked actor signs in; a new person gets an account (email unverified,
  like a fresh password registration); an existing unlinked account with that
  email is refused with a message that names the way forward.
- That way forward: "OrangeCat verbinden" on the profile. POST /api/user/orangecat
  mints a signed ten-minute cookie for the signed-in user; the sign-in callback
  reads it and attaches the OrangeCat identity to THAT account and no other.
- Staff is untouched: is_staff stays the sole grant, whatever the sign-in.

Provider config mirrors Solon/Heidi/Loki (client_secret_post, PKCE + state,
openid profile email). Env pair documented in .env.example; the client is
registered on the OrangeCat box with scripts/oauth/register-client.ts.

Verified: the pure module typechecks and its 10 tests pass; prettier and
lint:umlauts clean. A full tsc/lint run was not possible in the sandbox (the
ai-forms GitHub tarball is blocked there); CI is the gate.

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

* fix(auth): typecheck and docs-path check for the OrangeCat sign-in

- OrangeCatSection: apiFetch may resolve undefined; fall back to the
  hidden state instead of passing undefined to setState (CI tsc).
- CLAUDE.md: name orangecat's ADR-0009 without a path the docs-paths
  checker reads as local.

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

* fix(auth): OrangeCat section reads the apiFetch envelope; strings in every locale

- apiFetch resolves { success, data?, error? }; the section typed the payload
  as the envelope (CI tsc). Read data on success, treat a refused link intent
  as an error instead of starting the round-trip anyway.
- The nine new strings translated into fr, it, es, ru, ja, ko so the i18n
  audit's baseline stays where it is.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 03:42:06 -07:00
CatoandClaude Fable 5.1 e2c67d8aa5 chore(cleanup): dedupe migrations, blog scripts, i18n baseline; rate limiting over limitkit; no-console (#488)
* chore(db): empty the two byte-identical duplicate migrations instead of skipping one

004_ai_inventory_system.sql and 005_messaging_system.sql were 402- and
295-line copies of 004b and 005c (the originals were renamed with a suffix
in 21a6b2477, then re-added unsuffixed in e920eb231). Both names are
recorded in production's schema_migrations — backfilled by
083_backfill_schema_migrations.sql, which lists all four filenames — so
neither file can be deleted without a restore-from-backup audit reading it
as a vanished migration.

The bodies are gone; each file keeps a comment with the history. Applied
as a no-op, so the MIGRATION_SUPERSEDED skip list in migration-order.sh
(which existed only because 005's unguarded CREATE TRIGGERs aborted a
second application) is no longer needed and is removed from all three
runners' comments. The deploy script was not run; evidence is read from
the migration files and the runner sources only.

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

* chore(scripts): delete the Strapi-era blog and docker setup scripts

scripts/setup-blog.sh and scripts/start-blog.sh were byte-identical copies
of tools/development/setup-blog.sh and start-blog.sh; all four drove a
Strapi blog that no longer exists (the blog is DB-backed, no compose file
has a Strapi service, and .gitignore's /strapi entry pointed at nothing).
tools/development/docker-setup.sh was the wrapper around the same stack.
Nothing in package.json, CI or the docs invoked any of them; the one
prose mention in docs/guides/system-integration.md now says so.

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

* fix(i18n): baseline states each missing key once, not once per locale

scripts/baselines/i18n-missing.json listed the same ~90 keys under each of
six locales — six near-identical blocks that jscpd flagged as the repo's
largest clone group. The generator now writes one entry per key naming
the locales it is missing from; the audit converts back to the per-locale
view it compares against, so its regression semantics are unchanged
(0 new, 0 fixed on regeneration).

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

* refactor(security): one rate limiter over limitkit, lockout kept apart

Two hand-rolled limiters served ~20 routes each: an lru-cache counter in
lib/security/rate-limit.ts and a bare-Map window in lib/auth/rate-limiter.ts.
Both are replaced by the fleet's limitkit (SHARED.md); evig keeps only its
limit VALUES and the call shapes routes were written against, so no route
changed beyond its import. The auth file's account-lockout half — a
per-account, DB-backed state, not rate limiting — lives on as
lib/auth/lockout.ts. AUTH_CONFIG.rateLimit moves next to the other limits
as AUTH_RATE_LIMITS; lru-cache is dropped.

Behaviour that changed underneath, deliberately: sliding windows instead
of a TTL that restarted on every hit, refusals no longer count (a hammered
key recovers when the attacker stops), the client IP is the last
X-Forwarded-For hop (the one Caddy wrote), and the store is bounded. The
login limit was "5 per 15 min then a 30-min block"; limitkit does not
model a punitive block, so it is 5 per sliding 30 minutes — the same
steady-state admission.

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

* chore(lint): no-console in src/, and a useMounted hook for the SSR mount flag

App code logs through src/lib/logger.ts, the one console sink. ESLint now
enforces no-console (warn/error allowed) across src/, with the logger and
tests carved out; scripts/ are CLIs whose stdout is their output and stay
uncovered.

Four components each carried a useState(false)+useEffect(setMounted(true))
pair with a react-hooks/set-state-in-effect exception. They share one
useMounted() built on useSyncExternalStore, which needs no effect and no
exception.

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

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 22:42:11 -07:00
GandClaude Fable 5 fed2289a2d fix(money): invoices charged the pre-2024 VAT rate — consolidate to one SSOT (#368)
Switzerland raised standard VAT from 7.7% to 8.1% on 2024-01-01. The rate
was declared in five places — lib/pricing, lib/payments/tax-compliance,
lib/payments/currency (twice), the zod default in api/invoices and the
invoices.tax_rate column default — and every copy carried the old rate.
Two of those files each described themselves as 'the SSOT for VAT'.

Meanwhile lib/services/payment-webhook books Kivvi at 8.1%, and its own
comment flagged the divergence as a follow-up nobody closed. So the
platform issued invoices at one rate and posted the accounting entry at
another, on every paid order.

- src/config/tax.ts is now the only declaration; everything derives.
- getVATRateLabel() returned a literal '7.7' — that string is printed on
  invoices, so customers were shown a rate that also wasn't charged.
- Migration 140 moves the invoices.tax_rate default to 0.0810. Existing
  rows are NOT back-filled: the column records what was actually charged,
  and rewriting it would falsify history rather than correct it. Any
  commercial correction is a business decision.
- ~25 assertions across six suites pinned the old rate, so correcting it
  looked like a regression. They now derive from the constant; the literal
  rate is asserted in exactly one place (config/__tests__/tax-ssot.test.ts),
  which also fails if any source file hardcodes 0.077 again.

Verified: migration applied to a real database (it initially targeted the
wrong table — caught by applying it rather than reading it), 7802 tests,
typecheck, lint 0 errors, umlaut gate clean.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 20:02:40 +02:00
Mao NakamotoandClaude Opus 4.8 9ef3c02008 rebrand(evig): identity SSOT, i18n, README, logo assets [Layer A/1]
- org.ts: name/mission/founding → evig; positioning = affordable intelligence
- KILL money-routing: blank revamp-it IBAN; add PAYMENT (BTC + OrangeCat, TODO)
- blank infra-coupled fields evig lacks (phone, legacy site, external shops)
- i18n: brand tokens → evig across all locales (values only, keys untouched)
- README + logo assets → evig

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 12:19:40 +02:00
Mao NakamotoandClaude Opus 4.8 7615dc8da0 feat(blog): 3-level audience access control (public/team/author)
Adds an `audience` axis to blog posts, orthogonal to the existing
`visibility` (discoverability) column:
  - public — anyone (default; every existing post, via migration default)
  - team   — logged-in staff only (session.user.isStaff)
  - author — the author (created_by) + super admins only

SSOT: enum + labels + parser in src/config/blog.ts; one access helper
(src/lib/blog-access.ts, canViewPost/filterViewable) reused at every read
surface — index, post page + generateMetadata, RSS, sitemap, comments API.
Admin editor gains a "Zugriff" select (config-driven) and the list shows a
per-post access badge. Migration 138 is additive (ADD COLUMN ... DEFAULT
'public', no CHECK — app-validated per migration-110 policy).

Verified: typecheck, lint, 83 blog tests (incl. new blog-access truth table),
lint:umlauts — all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 09:03:21 +02:00
Mao NakamotoandClaude Fable 5 ebc1de2774 feat(zeiterfassung): shareable Monatsrapport link for social workers
The approver has to get the monthly report to a referring social worker, who
can't log in to the admin report page — and app email isn't reliably
deliverable (unauthenticated sending domain). So deliver it the way the
codebase already delivers deliverables: an unguessable public bearer link.

- Migration 137 `report_shares` (token, user_id, month, revoked_at) — keyed by
  (user_id, month), since a running month may have no timecard row yet.
- `report-shares.ts` service: ensure/lookup/revoke, mirroring the deliverables
  share_token pattern.
- Extract the report body into a shared, presentational `<MonthlyReportSheet>`
  (+ neutral `<ReportPrintButton>`), reused by the admin page and the new
  public page — no behaviour change to the admin sheet.
- Public `/r/[token]` route (view + print, never indexed, no auth); `/r/` added
  to proxy BYPASS_INTL.
- `<ReportShareCard>` on the admin report page: create / copy / revoke the link.
  Same access rule as viewing the report (owner or timecard approver).

Migration already applied + recorded on prod.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 18:34:15 +02:00
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
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 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 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 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 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 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 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
Mao NakamotoandCursor 0a4bc822bc feat(hr): talent lifecycle — vacancies, applications, /karriere, hire bridge
Adds end-to-end HR pipeline from public job postings through admin review to
team_profiles on hire, with migrations, E2E journey, and runbook docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 09:01:30 +02:00
Mao NakamotoandCursor 199e686351 feat(e2e,ci): workshop proposal journey + migration drift gate
Add dual-persona E2E for workshop propose/approve/reject (#61–62) and wire it
into post-deploy inventory. CI now replays all migrations on pgvector Postgres
with idempotent guards so fresh-DB apply matches prod evolution.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 16:10:39 +02:00
Mao NakamotoandCursor e4411bfd4f fix(db): Hetzner-only DATABASE_URL SSOT and user/admin E2E smoke
Retire cloud DB and AUTH_DB_* split in code, env examples, and docs so
local dev uses Docker Postgres and prod ops use the Hetzner tunnel pattern.
Add Playwright user-admin-flows spec with locale-aware auth helper.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 13:04:46 +02:00