diff --git a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/PreparePanel.tsx b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/PreparePanel.tsx index 2ede9f0..1e484a4 100644 --- a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/PreparePanel.tsx +++ b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/PreparePanel.tsx @@ -1,7 +1,6 @@ 'use client'; import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; -import { TextFillForm } from './TextFillForm'; import { PreviewModal } from './PreviewModal'; interface PreparePanelProps { @@ -14,6 +13,9 @@ interface PreparePanelProps { clientPropertyAddress?: string | null; previewToken: string | null; onPreviewTokenChange: (token: string | null) => void; + textFillData: Record; + selectedFieldId: string | null; + onQuickFill: (fieldId: string, value: string) => void; } function parseEmails(raw: string | undefined): string[] { @@ -24,16 +26,18 @@ function isValidEmail(email: string): boolean { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); } -export function PreparePanel({ docId, defaultEmail, clientName, currentStatus, agentDownloadUrl, signedAt, clientPropertyAddress, previewToken, onPreviewTokenChange }: PreparePanelProps) { +export function PreparePanel({ + docId, defaultEmail, clientName, currentStatus, + agentDownloadUrl, signedAt, clientPropertyAddress, + previewToken, onPreviewTokenChange, + textFillData, selectedFieldId, onQuickFill, +}: PreparePanelProps) { const router = useRouter(); const [recipients, setRecipients] = useState(defaultEmail ?? ''); // Sync if defaultEmail arrives after initial render (streaming / hydration timing) useEffect(() => { if (defaultEmail) setRecipients(defaultEmail); }, [defaultEmail]); - const [textFillData, setTextFillData] = useState>( - () => (clientPropertyAddress ? { propertyAddress: clientPropertyAddress } : {} as Record) - ); const [loading, setLoading] = useState(false); const [result, setResult] = useState<{ ok: boolean; message: string } | null>(null); const [previewBytes, setPreviewBytes] = useState(null); @@ -89,11 +93,6 @@ export function PreparePanel({ docId, defaultEmail, clientName, currentStatus, a ); } - function handleTextFillChange(data: Record) { - setTextFillData(data); - onPreviewTokenChange(null); - } - async function handlePreview() { setLoading(true); setResult(null); @@ -184,12 +183,48 @@ export function PreparePanel({ docId, defaultEmail, clientName, currentStatus, a

+ {/* Quick-fill panel — only shown when a text field is selected */}
- - + + {selectedFieldId ? ( +
+

+ Click a suggestion to fill the selected field. +

+ {clientName && ( + + )} + {clientPropertyAddress && ( + + )} + +
+ ) : ( +

+ Click a text field on the document to edit or quick-fill it. +

+ )}
- - updateRow(i, 'label', e.target.value)} - className="w-full border rounded px-2 py-1.5 text-sm focus:border-[var(--gold)] focus:ring-[var(--gold)]" - /> - Value - updateRow(i, 'value', e.target.value)} - className="w-full border rounded px-2 py-1.5 text-sm focus:border-[var(--gold)] focus:ring-[var(--gold)]" - /> - - ))} - {rows.length < 10 && ( - - )} - - ); -}