feat(16-01): thread signers and unassignedFieldIds through PdfViewer chain to FieldPlacer

- PdfViewerWrapper accepts and passes signers/unassignedFieldIds to PdfViewer
- PdfViewer accepts and passes both props to FieldPlacer
- FieldPlacer adds signers/unassignedFieldIds to FieldPlacerProps (optional, defaulted to []/ new Set())
- No rendering changes — prop tunnel only for Wave 2 consumers

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chandler Copeland
2026-04-03 16:21:20 -06:00
parent ac1f1d6cec
commit 9da2cc67fd
3 changed files with 18 additions and 2 deletions

View File

@@ -13,7 +13,7 @@ import {
} from '@dnd-kit/core'; } from '@dnd-kit/core';
import { CSS } from '@dnd-kit/utilities'; import { CSS } from '@dnd-kit/utilities';
import { getFieldType, type SignatureFieldType } from '@/lib/db/schema'; import { getFieldType, type SignatureFieldType } from '@/lib/db/schema';
import type { SignatureFieldData } from '@/lib/db/schema'; import type { SignatureFieldData, DocumentSigner } from '@/lib/db/schema';
interface PageInfo { interface PageInfo {
originalWidth: number; originalWidth: number;
@@ -164,9 +164,11 @@ interface FieldPlacerProps {
onFieldSelect?: (fieldId: string | null) => void; onFieldSelect?: (fieldId: string | null) => void;
onFieldValueChange?: (fieldId: string, value: string) => void; onFieldValueChange?: (fieldId: string, value: string) => void;
aiPlacementKey?: number; aiPlacementKey?: number;
signers?: DocumentSigner[];
unassignedFieldIds?: Set<string>;
} }
export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = false, onFieldsChanged, selectedFieldId, textFillData, onFieldSelect, onFieldValueChange, aiPlacementKey = 0 }: FieldPlacerProps) { export function FieldPlacer({ docId, pageInfo, currentPage, children, readOnly = false, onFieldsChanged, selectedFieldId, textFillData, onFieldSelect, onFieldValueChange, aiPlacementKey = 0, signers = [], unassignedFieldIds = new Set() }: FieldPlacerProps) {
const [fields, setFields] = useState<SignatureFieldData[]>([]); const [fields, setFields] = useState<SignatureFieldData[]>([]);
const [isDraggingToken, setIsDraggingToken] = useState<string | null>(null); const [isDraggingToken, setIsDraggingToken] = useState<string | null>(null);
const containerRef = useRef<HTMLDivElement | null>(null); const containerRef = useRef<HTMLDivElement | null>(null);

View File

@@ -4,6 +4,7 @@ import { Document, Page, pdfjs } from 'react-pdf';
import 'react-pdf/dist/Page/AnnotationLayer.css'; import 'react-pdf/dist/Page/AnnotationLayer.css';
import 'react-pdf/dist/Page/TextLayer.css'; import 'react-pdf/dist/Page/TextLayer.css';
import { FieldPlacer } from './FieldPlacer'; import { FieldPlacer } from './FieldPlacer';
import type { DocumentSigner } from '@/lib/db/schema';
// Worker setup — must use import.meta.url for local/Docker environments (no CDN) // Worker setup — must use import.meta.url for local/Docker environments (no CDN)
pdfjs.GlobalWorkerOptions.workerSrc = new URL( pdfjs.GlobalWorkerOptions.workerSrc = new URL(
@@ -28,6 +29,8 @@ export function PdfViewer({
onFieldSelect, onFieldSelect,
onFieldValueChange, onFieldValueChange,
aiPlacementKey, aiPlacementKey,
signers,
unassignedFieldIds,
}: { }: {
docId: string; docId: string;
docStatus?: string; docStatus?: string;
@@ -37,6 +40,8 @@ export function PdfViewer({
onFieldSelect?: (fieldId: string | null) => void; onFieldSelect?: (fieldId: string | null) => void;
onFieldValueChange?: (fieldId: string, value: string) => void; onFieldValueChange?: (fieldId: string, value: string) => void;
aiPlacementKey?: number; aiPlacementKey?: number;
signers?: DocumentSigner[];
unassignedFieldIds?: Set<string>;
}) { }) {
const [numPages, setNumPages] = useState(0); const [numPages, setNumPages] = useState(0);
const [pageNumber, setPageNumber] = useState(1); const [pageNumber, setPageNumber] = useState(1);
@@ -98,6 +103,8 @@ export function PdfViewer({
onFieldSelect={onFieldSelect} onFieldSelect={onFieldSelect}
onFieldValueChange={onFieldValueChange} onFieldValueChange={onFieldValueChange}
aiPlacementKey={aiPlacementKey} aiPlacementKey={aiPlacementKey}
signers={signers}
unassignedFieldIds={unassignedFieldIds}
> >
<Document <Document
file={`/api/documents/${docId}/file`} file={`/api/documents/${docId}/file`}

View File

@@ -1,5 +1,6 @@
'use client'; 'use client';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import type { DocumentSigner } from '@/lib/db/schema';
const PdfViewer = dynamic(() => import('./PdfViewer').then(m => m.PdfViewer), { ssr: false }); const PdfViewer = dynamic(() => import('./PdfViewer').then(m => m.PdfViewer), { ssr: false });
@@ -12,6 +13,8 @@ export function PdfViewerWrapper({
onFieldSelect, onFieldSelect,
onFieldValueChange, onFieldValueChange,
aiPlacementKey, aiPlacementKey,
signers,
unassignedFieldIds,
}: { }: {
docId: string; docId: string;
docStatus?: string; docStatus?: string;
@@ -21,6 +24,8 @@ export function PdfViewerWrapper({
onFieldSelect?: (fieldId: string | null) => void; onFieldSelect?: (fieldId: string | null) => void;
onFieldValueChange?: (fieldId: string, value: string) => void; onFieldValueChange?: (fieldId: string, value: string) => void;
aiPlacementKey?: number; aiPlacementKey?: number;
signers?: DocumentSigner[];
unassignedFieldIds?: Set<string>;
}) { }) {
return ( return (
<PdfViewer <PdfViewer
@@ -32,6 +37,8 @@ export function PdfViewerWrapper({
onFieldSelect={onFieldSelect} onFieldSelect={onFieldSelect}
onFieldValueChange={onFieldValueChange} onFieldValueChange={onFieldValueChange}
aiPlacementKey={aiPlacementKey} aiPlacementKey={aiPlacementKey}
signers={signers}
unassignedFieldIds={unassignedFieldIds}
/> />
); );
} }