From ac1f1d6cec817e583d65787d054155c1721a18e4 Mon Sep 17 00:00:00 2001 From: Chandler Copeland Date: Fri, 3 Apr 2026 16:21:13 -0600 Subject: [PATCH] feat(16-01): thread signers state through DocumentPageClient - Server page passes doc.signers as initialSigners to DocumentPageClient - DocumentPageClient adds signers + unassignedFieldIds state (initialized from server) - Props threaded to PdfViewerWrapper (signers, unassignedFieldIds) and PreparePanel (signers, onSignersChange, unassignedFieldIds, onUnassignedFieldIdsChange) - PreparePanel interface extended to accept new optional multi-signer props Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../[docId]/_components/DocumentPageClient.tsx | 11 +++++++++++ .../documents/[docId]/_components/PreparePanel.tsx | 6 ++++++ .../app/portal/(protected)/documents/[docId]/page.tsx | 1 + 3 files changed, 18 insertions(+) diff --git a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/DocumentPageClient.tsx b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/DocumentPageClient.tsx index b0c18fa..3899589 100644 --- a/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/DocumentPageClient.tsx +++ b/teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/DocumentPageClient.tsx @@ -2,6 +2,7 @@ import { useState, useCallback } from 'react'; import { PdfViewerWrapper } from './PdfViewerWrapper'; import { PreparePanel } from './PreparePanel'; +import type { DocumentSigner } from '@/lib/db/schema'; interface DocumentPageClientProps { docId: string; @@ -11,6 +12,7 @@ interface DocumentPageClientProps { agentDownloadUrl?: string | null; signedAt?: Date | null; clientPropertyAddress?: string | null; + initialSigners: DocumentSigner[]; } export function DocumentPageClient({ @@ -21,11 +23,14 @@ export function DocumentPageClient({ agentDownloadUrl, signedAt, clientPropertyAddress, + initialSigners, }: DocumentPageClientProps) { const [previewToken, setPreviewToken] = useState(null); const [selectedFieldId, setSelectedFieldId] = useState(null); const [textFillData, setTextFillData] = useState>({}); const [aiPlacementKey, setAiPlacementKey] = useState(0); + const [signers, setSigners] = useState(initialSigners); + const [unassignedFieldIds, setUnassignedFieldIds] = useState>(new Set()); const handleFieldsChanged = useCallback(() => { setPreviewToken(null); @@ -71,6 +76,8 @@ export function DocumentPageClient({ onFieldSelect={setSelectedFieldId} onFieldValueChange={handleFieldValueChange} aiPlacementKey={aiPlacementKey} + signers={signers} + unassignedFieldIds={unassignedFieldIds} />
@@ -88,6 +95,10 @@ export function DocumentPageClient({ selectedFieldId={selectedFieldId} onQuickFill={handleQuickFill} onAiAutoPlace={handleAiAutoPlace} + signers={signers} + onSignersChange={setSigners} + unassignedFieldIds={unassignedFieldIds} + onUnassignedFieldIdsChange={setUnassignedFieldIds} />
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 92c09c9..36ab6aa 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 @@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import dynamic from 'next/dynamic'; +import type { DocumentSigner } from '@/lib/db/schema'; // PreviewModal imports react-pdf which calls new DOMMatrix() at module level — // must be loaded client-only to avoid SSR crash, same pattern as PdfViewer. @@ -21,6 +22,11 @@ interface PreparePanelProps { selectedFieldId: string | null; onQuickFill: (fieldId: string, value: string) => void; onAiAutoPlace: () => Promise; + // Multi-signer props — wired in Phase 16, consumed in Wave 2 + signers?: DocumentSigner[]; + onSignersChange?: (signers: DocumentSigner[]) => void; + unassignedFieldIds?: Set; + onUnassignedFieldIdsChange?: (ids: Set) => void; } function parseEmails(raw: string | undefined): string[] { 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 133543d..6569440 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 @@ -60,6 +60,7 @@ export default async function DocumentPage({ agentDownloadUrl={agentDownloadUrl} signedAt={doc.signedAt ?? null} clientPropertyAddress={docClient?.propertyAddress ?? null} + initialSigners={doc.signers ?? []} /> );