fix(audit-wave-9): unified template token picker with custom-field group
Build a shared <TemplateTokenPicker> that renders the canonical
MERGE_FIELDS catalog grouped by scope, plus a dynamically-fetched
"Custom (port-specific)" group surfaced from /api/v1/admin/custom-fields.
The custom group is filtered to entity types the resolver actually
expands at send time (client/interest/berth - see
mergeCustomFieldValues in document-sends.service).
Wire it into both consumers:
- admin/document-templates/template-form.tsx (replaces TEMPLATE_VARIABLES
list which had drifted from the canonical catalog)
- admin/sales-email-config-card.tsx (replaces flat alphabetical dump)
Closes custom-fields §B "UI surfacing of {{custom.…}} tokens".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,7 @@ import { Label } from '@/components/ui/label';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { apiFetch } from '@/lib/api/client';
|
||||
import { VALID_MERGE_TOKENS } from '@/lib/templates/merge-fields';
|
||||
import { TemplateTokenPicker } from '@/components/admin/shared/template-token-picker';
|
||||
import { toastError } from '@/lib/api/toast-error';
|
||||
|
||||
interface SalesConfigResponse {
|
||||
@@ -313,14 +313,10 @@ export function SalesEmailConfigCard() {
|
||||
<CardContent className="space-y-4">
|
||||
<details className="rounded-md border bg-muted/30 px-3 py-2 text-xs">
|
||||
<summary className="cursor-pointer font-medium text-foreground">
|
||||
Available tokens ({Array.from(VALID_MERGE_TOKENS).length})
|
||||
Available tokens
|
||||
</summary>
|
||||
<div className="mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground sm:grid-cols-3">
|
||||
{Array.from(VALID_MERGE_TOKENS)
|
||||
.sort()
|
||||
.map((tok) => (
|
||||
<span key={tok}>{tok}</span>
|
||||
))}
|
||||
<div className="mt-3">
|
||||
<TemplateTokenPicker />
|
||||
</div>
|
||||
</details>
|
||||
<Field
|
||||
|
||||
Reference in New Issue
Block a user