feat(post-audit): Phase 5 partial (4/8 templates) + 7.1 editor scaffold + per-entity reminder buttons

Phase 5 — luxury-port email tone (4 of 8 templates):
- portal-auth.tsx — activation + reset: "It's our pleasure to invite
  you to the {portName} client portal — your private space to review
  your berth, manage signed documents, and stay in touch with your
  sales liaison", sign-off "With warm regards, The {portName} Team",
  subjects "Welcome to {portName} — activate your client portal" /
  "Reset your {portName} portal password".
- inquiry-client-confirmation.tsx — "We've noted your enquiry, and a
  member of our team will be in touch shortly through your preferred
  channel", "should anything come to mind in the meantime", sign-off
  "With warm regards, The {portName} Sales Team".
- notification-digest.tsx — "Your {portName} update" header, "Here's
  what's waiting for you", "With warm regards, The {portName} Team".
- document-signing.tsx — all 4 sign-offs ("Dear X, ... Thank you, The
  {portName} team") rewritten to "With warm regards, The {portName} Team"
  with capitalised Team for consistency.
- Voice captured from old-CRM Nuxt repo
  (/Users/matt/Repos/Port Nimara/Port Nimara Client Portal/client-portal/
  server/utils/signature-notifications.ts) which already used "Dear",
  "Best regards", and collective sign-offs.

Remaining 4 templates (admin-email-change, crm-invite,
inquiry-sales-notification, residential-inquiry) + cross-port snapshot
tests queued as follow-up.

Phase 7.1 — PDF editor scaffold:
- New admin route /admin/templates/[id]/editor/page.tsx wired to a
  client-side <TemplateEditor>.
- Renders page 1 via react-pdf (worker URL pattern mirrors
  components/files/pdf-viewer.tsx); click-to-place markers in percent
  coordinates so a future page-size swap doesn't shift placements.
- Token picker over VALID_MERGE_TOKENS (sorted).
- Save persists overlayPositions via PATCH against the existing
  document_templates row; validator accepts the new field via
  fieldMapSchema from lib/templates/field-map.ts (no migration needed
  — overlay_positions JSONB column already exists).
- Outer/inner-body split + key-by-templateId remount avoids the
  in-render setState antipattern when seeding from server data.
- Add + delete markers supported. Multi-page, drag, resize, preview,
  new-PDF upload all defer to 7.2.

Per-entity polish:
- [+ Reminder] button on yacht / client / interest detail headers,
  threading defaultYachtId / defaultClientId / defaultInterestId so the
  ReminderForm opens with the entity pre-linked.
- [EOI] badge on yacht detail header when yacht.source === 'eoi-generated'
  (mirrors the contacts-editor pattern shipped in eaab149).

Phase 6 hardening:
- imap-bounce-poller strips whitespace from IMAP_PASS so Google
  Workspace App Passwords (16-char "abcd efgh ijkl mnop" format) work
  whether pasted with or without spaces. Confirmed via Google docs that
  the visual spaces are formatting only and must not reach the IMAP
  server.

Quality gates: 1374/1374 vitest, tsc clean, lint 0 errors.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 16:37:19 +02:00
parent eaab14943b
commit f938847ed9
12 changed files with 502 additions and 65 deletions

View File

@@ -884,8 +884,12 @@ Deferred:
so the EOI's yacht block populates without a manual re-link.
- ☑ 3d — `POST /api/v1/clients/:id/contacts/:contactId/promote-to-primary`
(transactional demote+promote via `promoteContactToPrimary`); `[EOI]`
badge on non-primary contact rows in `<ContactsEditor>` with title-attr
explainer. Yacht detail-page badge deferred.
badge on non-primary contact rows in `<ContactsEditor>` + on yacht
detail header when `yacht.source === 'eoi-generated'`.
- ☐ Address override field in EOI dialog (schema columns exist)
- ☐ Audit-log UI surfacing of new verbs (rows written, filter chips missing)
- ☐ Backfill yachts.source_document_id after EOI document is created
(currently set NULL because the yacht is spawned BEFORE the doc row exists)
- ◐ Phase 4 — Reminders (fb4a09e + session 2026-05-18 PM)
- ☑ Schema migration 0072: reminders.yacht_id + fired_at + interests.reminder_note
- ☑ Service + validators accept yachtId with port-scoping check
@@ -898,10 +902,18 @@ Deferred:
- ☑ `user_profiles.preferences.digestTimeOfDay` picker on `/settings`
(time input + help text). `<ReminderForm>` honours the preference via
a React-Query me-prefs fetch keyed `['me', 'preferences']`.
- Per-entity-page `[+ Task]` buttons threading `defaultYachtId` (etc.)
- ◐ Phase 5 — Email-copy refactor (branding chain only; df1594d)
- Per-entity `[+ Reminder]` buttons on yacht / client / interest detail
headers threading defaultYachtId / defaultClientId / defaultInterestId
- ☐ Per-entity reminders LIST inline on detail pages (button exists; section TBD)
- ◐ Phase 5 — Email-copy refactor (df1594d + 2026-05-18 PM)
- ☑ Per-port background URL — closes the last hard-coded portnimara.com asset
- ☐ Tone rewrite across 8 templates using old-CRM Nuxt repo as reference
- ☑ 4/8 templates rewritten with luxury-port voice (portal-auth activation
- reset, inquiry-client-confirmation, notification-digest, document-signing
sign-offs). Voice captured from old-CRM Nuxt repo `server/utils/
signature-notifications.ts` ("Dear X", "With warm regards, The
{portName} Team").
- ☐ Remaining 4 templates: admin-email-change, crm-invite,
inquiry-sales-notification, residential-inquiry
- ☐ Snapshot tests per template at port-nimara + 2nd test port
- ◐ Phase 6 — IMAP bounce-to-interest linking (9f57868 + session 2026-05-18 PM)
- ☑ Schema migration 0074: bounce_status/reason/detected_at on document_sends
@@ -927,10 +939,17 @@ Deferred:
envelope sender's mailbox (the SMTP user account), so pointing the
poller at that single mailbox catches every automated-email bounce
in one place.
- ◐ Phase 7 — PDF template editor (field-map types only; 9f57868)
- ◐ Phase 7 — PDF template editor (9f57868 + 2026-05-18 PM)
- ☑ FieldMap type definitions + Zod validators + page-count cross-validator
- 7.1 Read + place (~2 weeks): editor shell, page picker, marker drop
- ☐ 7.2 Edit + preview (~1-2 weeks): drag/resize, live preview, new-PDF upload
- 7.1 scaffold — `/admin/templates/[id]/editor/page.tsx` + client-side
`<TemplateEditor>` with react-pdf, click-to-place markers, token picker
from `VALID_MERGE_TOKENS`, save via PATCH to overlayPositions. Page 1
only; add + delete markers supported.
- ☐ 7.1 polish: unsaved-changes guard, responsive PDF width,
"required tokens unplaced" indicator
- ☐ 7.2 Edit + preview (~1-2 weeks): drag/resize, live preview pane with
sample interest data, multi-page navigation, new-PDF upload (replace
source while preserving field map)
---