feat(inquiries): triage workflow on the inbox (R2-M2)

The inquiry inbox was read-only — every inquiry stayed there forever
with no way to mark "I handled this" or "this is spam." Now:

- Migration 0045 adds triage_state ('open' | 'assigned' | 'converted'
  | 'dismissed' default 'open') + triaged_at + triaged_by columns to
  website_submissions, plus a (port_id, triage_state, received_at)
  index for the inbox query.
- New PATCH /api/v1/admin/website-submissions/[id]/triage flips the
  state with audit log entry.
- List endpoint takes a `state` filter (default 'inbox' = open +
  assigned, hides converted + dismissed).
- UI: per-row Convert / Assign / Dismiss / Reopen actions; second
  filter row for state; triage badge per card. "Convert" jumps to
  /clients with prefill_name / prefill_email / prefill_phone /
  prefill_source / prefill_inquiry_id query params + marks the row
  converted (the client-create form will read those — same prefill
  pattern other entry points use).

1175/1175 vitest passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-05-06 23:48:59 +02:00
parent 0f648a924b
commit f3143d7561
5 changed files with 236 additions and 9 deletions

View File

@@ -0,0 +1,18 @@
-- Inquiry-inbox triage workflow. Adds three columns to
-- website_submissions so the inbox isn't permanent dead weight:
--
-- triage_state: 'open' | 'converted' | 'dismissed' | 'assigned'
-- triaged_at: timestamptz when the state last changed
-- triaged_by: user id who set the state
--
-- Default 'open' so backfill leaves history visible. The default
-- inbox query filters to open + assigned so resolved/dismissed roll
-- off without being permanently lost.
ALTER TABLE website_submissions
ADD COLUMN IF NOT EXISTS triage_state text NOT NULL DEFAULT 'open',
ADD COLUMN IF NOT EXISTS triaged_at timestamptz,
ADD COLUMN IF NOT EXISTS triaged_by text;
CREATE INDEX IF NOT EXISTS idx_ws_triage_state
ON website_submissions (port_id, triage_state, received_at DESC);