From 0a719c9d601cf17233d13ad97cefe09dba001645 Mon Sep 17 00:00:00 2001 From: Chandler Copeland Date: Fri, 20 Mar 2026 00:53:46 -0600 Subject: [PATCH] fix(05-04): fetch client email via direct join, improve recipients hint text --- .../[docId]/_components/PreparePanel.tsx | 8 +++---- .../(protected)/documents/[docId]/page.tsx | 23 +++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) 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 a16d985..1b232bf 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 @@ -87,11 +87,9 @@ export function PreparePanel({ docId, defaultEmail, clientName, currentStatus }: className="w-full border rounded px-2 py-1.5 text-sm resize-none" placeholder="email@example.com" /> - {clientName && ( -

- {clientName} ยท add more addresses separated by commas -

- )} +

+ To add more recipients, separate each email with a comma +

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 739e699..6cfd5dc 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 @@ -1,7 +1,7 @@ import { auth } from '@/lib/auth'; import { redirect } from 'next/navigation'; import { db } from '@/lib/db'; -import { documents } from '@/lib/db/schema'; +import { documents, clients } from '@/lib/db/schema'; import { eq } from 'drizzle-orm'; import Link from 'next/link'; import { PdfViewerWrapper } from './_components/PdfViewerWrapper'; @@ -17,10 +17,15 @@ export default async function DocumentPage({ const { docId } = await params; - const doc = await db.query.documents.findFirst({ - where: eq(documents.id, docId), - with: { client: true }, - }); + const [doc, docClient] = await Promise.all([ + db.query.documents.findFirst({ where: eq(documents.id, docId) }), + db.select({ email: clients.email, name: clients.name }) + .from(clients) + .innerJoin(documents, eq(documents.clientId, clients.id)) + .where(eq(documents.id, docId)) + .limit(1) + .then(r => r[0] ?? null), + ]); if (!doc) redirect('/portal/dashboard'); @@ -32,11 +37,11 @@ export default async function DocumentPage({ href={`/portal/clients/${doc.clientId}`} className="inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium text-blue-600 border border-blue-200 rounded-md bg-blue-50 hover:bg-blue-100 hover:border-blue-300 transition-colors" > - ← Back to {doc.client?.name ?? 'Client'} + ← Back to {docClient?.name ?? 'Client'}

{doc.name}

- {doc.client?.name} · {doc.status} + {docClient?.name} · {doc.status}

@@ -48,8 +53,8 @@ export default async function DocumentPage({