[Bug-1225] Fix team invitation Clerk roles

Story 1225Epic None7 files · +347/−52

PR #309 · pramaan-io/pramaan-app · merged 2026-06-12

Why this matters

When the wrong role walks in, the firm breaks.

Team invitations

A generic toast hides whether the invite was a duplicate, a rate-limit, or a rejection — and a raw role string lets Clerk assign the wrong access.

The fix — Map roles both ways; turn Clerk's errors into words the invite sheet can show.

How it flows

sequenceDiagram
  autonumber
  participant ui as Invite sheet
  participant server as Server (translator)
  participant clerk as Clerk org
  ui->>server: invite with PRAMAAN role
  server->>server: map to Clerk role (outbound)
  server->>clerk: createInvitation(org:firm_*)
  clerk-->>server: result or Clerk error
  server->>server: convert error to InviteApiError
  server->>ui: structured error + localized copy

Files changed (7)

File±
messages/en.json+3
messages/hi.json+3
src/components/settings/team/invite-member-sheet.tsx+1 −1
src/components/settings/team/use-team-list-actions.ts+16 −1
src/lib/team-invitations/hooks.ts ★+34 −2
src/lib/team-invitations/server.test.ts ★+166
src/lib/team-invitations/server.ts ★+124 −48