feat(post-audit): Phase 3 EOI overrides + 3c spawn + 3d promote + Phase 4 worker
Phase 3b — EOI dialog field overrides:
- New EoiOverridesInput shape (clientEmail / clientPhone / yachtName)
threaded through generate-and-sign validator + both pathways
(in-app pdf-lib fill, Documenso template generate).
- src/lib/services/eoi-overrides.service.ts applies side-effects in one
transaction: useOnlyForThisEoi writes documents.override_* and stops;
setAsDefault demotes the prior primary + promotes (existing contactId)
or inserts + promotes (fresh value); neither flag inserts a non-primary
client_contacts row for future dropdown reuse.
- Document override columns persisted post-insert, with a 1-minute
source_document_id backfill on freshly inserted contact rows.
- eoi-context route returns available.{emails, phones} so the dialog
can render combobox options.
- <OverridableContactField> in eoi-generate-dialog.tsx renders the
combobox + manual input + 2 checkboxes per field with mutually
exclusive intent semantics.
Phase 3c — yacht spawn from EOI dialog:
- YachtForm gains createExtras + onCreated callbacks; the EOI dialog
opens it as a nested Sheet pre-filled with the linked client as owner.
On save the new yacht is stamped source='eoi-generated' and the
interest is PATCHed with the new yachtId so the EOI context reflows.
Phase 3d — promote-to-primary + audit + [EOI] badge:
- POST /api/v1/clients/:id/contacts/:contactId/promote-to-primary
(transactional demote+promote via promoteContactToPrimary).
- src/lib/audit.ts AuditAction type adds eoi_field_override,
promote_to_primary, eoi_spawn_yacht (DB column is free-text).
- ContactsEditor surfaces an [EOI] badge on non-primary rows where
source='eoi-custom-input'.
Phase 4 — worker + TOD picker:
- processOverdueReminders refactored to UPDATE...RETURNING with a
fired_at IS NULL gate so parallel workers can't double-fire. Uses
the idx_reminders_due_unfired partial index from migration 0072.
- /settings gets a "Default reminder time" time-of-day picker; the
value lands in user_profiles.preferences.digestTimeOfDay (validated
HH:MM at the route). <ReminderForm> seeds its dueAt from this
preference via a React-Query me-prefs fetch.
Phase 6 hardening:
- IMAP bounce poller strips whitespace from IMAP_PASS so a copy-paste
of Google Workspace's 16-char App Password formatted as
"abcd efgh ijkl mnop" still authenticates. Workspace activation
procedure documented in MASTER-PLAN §Phase 6 (was previously written
to CLAUDE.md, which was bloat — moved to the plan).
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:
@@ -23,7 +23,7 @@ import type { CountryCode } from '@/lib/i18n/countries';
|
||||
|
||||
interface MeResponse {
|
||||
user?: { name: string; email: string };
|
||||
preferences?: { country?: string; timezone?: string };
|
||||
preferences?: { country?: string; timezone?: string; digestTimeOfDay?: string };
|
||||
profile?: {
|
||||
avatarFileId?: string | null;
|
||||
firstName?: string | null;
|
||||
@@ -45,6 +45,10 @@ export function UserSettings() {
|
||||
const [originalEmail, setOriginalEmail] = useState('');
|
||||
const [country, setCountry] = useState<string | null>(null);
|
||||
const [timezone, setTimezone] = useState<string | null>(null);
|
||||
/** Phase 4 — default reminder firing time-of-day (HH:MM). Drives the
|
||||
* `<ReminderForm>` "Due Date & Time" default when the rep creates a
|
||||
* reminder without explicitly picking a time. */
|
||||
const [digestTimeOfDay, setDigestTimeOfDay] = useState<string>('09:00');
|
||||
const [saving, setSaving] = useState<string | null>(null);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
const [resetMsg, setResetMsg] = useState<string | null>(null);
|
||||
@@ -84,6 +88,7 @@ export function UserSettings() {
|
||||
// saved yet — first-time users land on a sensible default rather
|
||||
// than an empty picker. Doesn't overwrite an explicit choice.
|
||||
setTimezone(res.data.preferences?.timezone ?? detectedTz ?? null);
|
||||
setDigestTimeOfDay(res.data.preferences?.digestTimeOfDay ?? '09:00');
|
||||
const fid = res.data.profile?.avatarFileId ?? null;
|
||||
setAvatarFileId(fid);
|
||||
setAvatarUrl(fid ? `/api/v1/files/${fid}/preview` : null);
|
||||
@@ -145,6 +150,7 @@ export function UserSettings() {
|
||||
preferences: {
|
||||
country: country ?? undefined,
|
||||
timezone: timezone ?? undefined,
|
||||
digestTimeOfDay: digestTimeOfDay || undefined,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -339,6 +345,20 @@ export function UserSettings() {
|
||||
</WarningCallout>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="settings-digest-tod">Default reminder time</Label>
|
||||
<Input
|
||||
id="settings-digest-tod"
|
||||
type="time"
|
||||
value={digestTimeOfDay}
|
||||
onChange={(e) => setDigestTimeOfDay(e.target.value)}
|
||||
className="w-32"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
When you create a reminder without picking a time, this is the time-of-day it
|
||||
defaults to. Per-reminder overrides still win.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<Button onClick={saveProfile} disabled={saving === 'profile'}>
|
||||
<Save className="mr-1.5 h-4 w-4" />
|
||||
|
||||
Reference in New Issue
Block a user