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 9956035..fb25259 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 @@ -10,6 +10,7 @@ interface PreparePanelProps { currentStatus: string; agentDownloadUrl?: string | null; signedAt?: Date | null; + clientPropertyAddress?: string | null; } function parseEmails(raw: string | undefined): string[] { @@ -20,14 +21,16 @@ function isValidEmail(email: string): boolean { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); } -export function PreparePanel({ docId, defaultEmail, clientName, currentStatus, agentDownloadUrl, signedAt }: PreparePanelProps) { +export function PreparePanel({ docId, defaultEmail, clientName, currentStatus, agentDownloadUrl, signedAt, clientPropertyAddress }: 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>({}); + const [textFillData, setTextFillData] = useState>( + () => (clientPropertyAddress ? { propertyAddress: clientPropertyAddress } : {} as Record) + ); const [loading, setLoading] = useState(false); const [result, setResult] = useState<{ ok: boolean; message: string } | null>(null); diff --git a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/page.tsx b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/page.tsx index 7613009..97773b5 100644 --- a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/page.tsx +++ b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/page.tsx @@ -20,7 +20,7 @@ export default async function DocumentPage({ const [doc, docClient] = await Promise.all([ db.query.documents.findFirst({ where: eq(documents.id, docId) }), - db.select({ email: clients.email, name: clients.name }) + db.select({ email: clients.email, name: clients.name, propertyAddress: clients.propertyAddress }) .from(clients) .innerJoin(documents, eq(documents.clientId, clients.id)) .where(eq(documents.id, docId)) @@ -65,6 +65,7 @@ export default async function DocumentPage({ currentStatus={doc.status} agentDownloadUrl={agentDownloadUrl} signedAt={doc.signedAt ?? null} + clientPropertyAddress={docClient?.propertyAddress ?? null} /> diff --git a/teressa-copeland-homes/src/app/portal/_components/ClientModal.tsx b/teressa-copeland-homes/src/app/portal/_components/ClientModal.tsx index 5bf894b..6db2a87 100644 --- a/teressa-copeland-homes/src/app/portal/_components/ClientModal.tsx +++ b/teressa-copeland-homes/src/app/portal/_components/ClientModal.tsx @@ -10,45 +10,28 @@ type ClientModalProps = { clientId?: string; defaultName?: string; defaultEmail?: string; + defaultPropertyAddress?: string; }; -export function ClientModal({ - isOpen, - onClose, - mode = "create", - clientId, - defaultName, - defaultEmail, -}: ClientModalProps) { - const boundAction = - mode === "edit" && clientId - ? updateClient.bind(null, clientId) - : createClient; - +export function ClientModal({ isOpen, onClose, mode = "create", clientId, defaultName, defaultEmail, defaultPropertyAddress }: ClientModalProps) { + const boundAction = mode === "edit" && clientId ? updateClient.bind(null, clientId) : createClient; const [state, formAction, pending] = useActionState(boundAction, null); useEffect(() => { - if (state?.success) { - onClose(); - } + if (state?.success) onClose(); }, [state, onClose]); if (!isOpen) return null; - const title = mode === "edit" ? "Edit Client" : "Add Client"; - return ( -
-
-

- {title} +
+
+

+ {mode === "edit" ? "Edit Client" : "Add Client"}

-
+
-
-
- {state?.error && ( -

{state.error}

- )} -
+
+ + +
+ {state?.error &&

{state.error}

} +
diff --git a/teressa-copeland-homes/src/app/portal/_components/ClientProfileClient.tsx b/teressa-copeland-homes/src/app/portal/_components/ClientProfileClient.tsx index 6d712e8..0774ab1 100644 --- a/teressa-copeland-homes/src/app/portal/_components/ClientProfileClient.tsx +++ b/teressa-copeland-homes/src/app/portal/_components/ClientProfileClient.tsx @@ -20,7 +20,7 @@ type DocumentRow = { }; type Props = { - client: { id: string; name: string; email: string }; + client: { id: string; name: string; email: string; propertyAddress?: string | null }; docs: DocumentRow[]; }; @@ -48,6 +48,9 @@ export function ClientProfileClient({ client, docs }: Props) {

{client.name}

{client.email}

+ {client.propertyAddress && ( +

{client.propertyAddress}

+ )}