Commit Graph
4 Commits
Author SHA1 Message Date
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 d37fcd9259 chore(notifications): prune 4 dead notification types
Removed `message`, `vacancy_published`, `marketing`, `task_broadcast` from
NOTIFICATION_TYPES — verified zero producers (no createNotification/notifyUsers
emits them, via constant or literal) and no label/icon/href map references them.
Kept `appointment`/`marketplace`/`system` (all have live producers). Dropped the
3 now-stale assertions in system-constants.test.ts.

typecheck clean; 42 notification-config tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 18:15:01 +02:00
Mao NakamotoandClaude Opus 4.8 0f02b951e0 fix(notifications): kill marketplace double-emails, add time-off ack, task_assigned SSOT
Three bounded email/notification follow-ups from docs/EMAILS.md:

- Marketplace double emails (#3): the seller createNotification in the listing
  question, order confirm-receipt and review routes each fired a generic email
  ON TOP of the dedicated styled email → seller got two. All three now pass
  { skipEmail: true } so only the styled email sends; the in-app bell entry
  stays (robust against deliverability drops).
- Time-off requester ack (#4): createTimeOffRequest now sends the requester an
  in-app time_off_requested confirmation at submit time (→ /admin/zeiterfassung),
  mirroring the timecard-submit confirmation. Previously the requester heard
  nothing until review.
- task_assigned SSOT (#5): added NOTIFICATION_TYPES.TASK_ASSIGNED; both task
  routes use the constant instead of a bare literal. Corrected the stale
  "DB CHECK must match" note in the config (that constraint was dropped in
  migration 110 — config + zod is the only enum authority now).

Also fixed the two task-route test mocks that stubbed @/config/notifications
with only RELATED_TYPES (they now include NOTIFICATION_TYPES so the constant
resolves).

typecheck + lint + umlauts clean; 151 marketplace/tasks/time-off/listings tests
green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 16:13:51 +02:00
Mao NakamotoandClaude Opus 4.8 8ba70bcee0 fix(notifications): wire missing emails (timecard/shop/service) + SSOT doc
Audited every notification trigger (docs/EMAILS.md) and fixed the gaps
the user hit:

- Timecard submitted: the SUBMITTER now gets an emailed confirmation
  (new timecard_submit_confirmed type), and when they're the sole
  approver it says they can approve it themselves. Before, the submitter
  got nothing and a sole-super-admin approver submitting their own card
  notified NOBODY (approver resolution excludes the submitter).
- Order placed: the SELLER now gets an in-app bell entry (listing_sold,
  skipEmail — the styled seller email already exists). Survives email
  deliverability drops. New RELATED_TYPES.ORDER → /dashboard/orders/.
- Service booking: the CUSTOMER is now acknowledged at booking time
  (in-app + email); before, only admins + the assigned repairer were.
- createNotification gains opts.skipEmail for in-app-only notifications
  (also the fix for the marketplace double-email follow-up).

docs/EMAILS.md is the new SSOT: full trigger table + deliverability
caveat (Brevo/SPF-DKIM) + remaining follow-ups (paid-webhook
confirmations, double-emails, time-off ack, task_assigned drift).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 11:43:16 +02:00