fix(19): revise plan 02 — remove client-text contradiction in handlePersist
This commit is contained in:
@@ -336,11 +336,11 @@ const [name, setName] = useState(templateName);
|
||||
|
||||
Callbacks:
|
||||
|
||||
`handlePersist` — the `onPersist` callback passed to PdfViewerWrapper (per D-01). Before saving, merge `textFillData` values into `field.hint` for client-text fields (per Research Pitfall 6):
|
||||
`handlePersist` — the `onPersist` callback passed to PdfViewerWrapper (per D-01). Before saving, merge `textFillData` values into `field.hint` for text fields (per Research Pitfall 6). IMPORTANT: The schema type value is `'text'` (from `SignatureFieldType`), NOT `'client-text'`. Use `f.type === 'text'` exactly:
|
||||
```typescript
|
||||
const handlePersist = useCallback(async (rawFields: SignatureFieldData[]) => {
|
||||
const fieldsWithHints = rawFields.map(f =>
|
||||
f.type === 'client-text' && textFillData[f.id]
|
||||
f.type === 'text' && textFillData[f.id]
|
||||
? { ...f, hint: textFillData[f.id] }
|
||||
: f
|
||||
);
|
||||
@@ -352,11 +352,6 @@ const handlePersist = useCallback(async (rawFields: SignatureFieldData[]) => {
|
||||
}, [templateId, textFillData]);
|
||||
```
|
||||
|
||||
Note: the `type` check uses `'client-text'` — however the actual schema type value for text fields is just `'text'`. Read the FieldPlacer palette token IDs to confirm the exact string. The existing codebase uses `type: 'text'` in SignatureFieldType. So the check should be:
|
||||
```typescript
|
||||
f.type === 'text' && textFillData[f.id]
|
||||
```
|
||||
|
||||
`handleFieldValueChange`:
|
||||
```typescript
|
||||
const handleFieldValueChange = useCallback((fieldId: string, value: string) => {
|
||||
@@ -576,12 +571,13 @@ Import `ConfirmDialog` from `@/app/portal/_components/ConfirmDialog` for role re
|
||||
- TemplatePageClient.tsx contains `fieldsUrl={\`/api/templates/${templateId}/fields\`}`
|
||||
- TemplatePageClient.tsx contains `fileUrl={\`/api/templates/${templateId}/file\`}`
|
||||
- TemplatePageClient.tsx contains `deriveRolesFromFields` function
|
||||
- TemplatePageClient.tsx contains `f.type === 'text'` (NOT `'client-text'`) in the hint-merge branch of handlePersist
|
||||
- TemplatePageClient.tsx contains `f.hint` or `hint:` for the hint merge in handlePersist
|
||||
- TemplatePanel.tsx contains `"Signers / Roles"` section heading
|
||||
- TemplatePanel.tsx contains `"AI Auto-place Fields"` button text
|
||||
- TemplatePanel.tsx contains `"Save Template"` button text
|
||||
- TemplatePanel.tsx contains `#C9A84C` (gold) and `#1B2B4B` (navy) colors
|
||||
- TemplatePanel.tsx contains `"Placing..."` or `"Placing…"` loading text
|
||||
- TemplatePanel.tsx contains `"Placing..."` or `"Placing..."` loading text
|
||||
- TemplatePanel.tsx contains `"Saved"` success text
|
||||
- TemplatePanel.tsx contains `ConfirmDialog` import for role removal
|
||||
- `npx tsc --noEmit` exits 0
|
||||
@@ -610,7 +606,7 @@ Import `ConfirmDialog` from `@/app/portal/_components/ConfirmDialog` for role re
|
||||
- Template editor is accessible at /portal/templates/[id]
|
||||
- FieldPlacer operates in template mode (onPersist saves to /api/templates/[id], fields load from /api/templates/[id]/fields, PDF loads from /api/templates/[id]/file)
|
||||
- Role labels (not emails) are used in the template editor
|
||||
- Text hints on client-text fields are merged into field.hint before persisting
|
||||
- Text hints on text fields (f.type === 'text') are merged into field.hint before persisting
|
||||
- AI Auto-place triggers POST /api/templates/[id]/ai-prepare
|
||||
- Save persists via PATCH /api/templates/[id]
|
||||
</success_criteria>
|
||||
|
||||
Reference in New Issue
Block a user