Commit Graph

128 Commits

Author SHA1 Message Date
Chandler Copeland
37f8691cac docs(05-02): complete pdf-fill-and-field-mapping plan 02
- FieldPlacer.tsx: dnd-kit drag-and-drop field placer with Y-flip coordinate conversion
- PdfViewer.tsx: extended with pageInfo state and FieldPlacer integration
- @dnd-kit/core and @dnd-kit/utilities installed
- Fields persist via PUT /api/documents/[id]/fields on every add/remove
- 05-02-SUMMARY.md created, STATE.md and ROADMAP.md updated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 00:01:59 -06:00
Chandler Copeland
7a367363b1 feat(05-02): extend PdfViewer with pageInfo state and FieldPlacer integration
- Add pageInfo state (PageInfo | null) to track rendered PDF page dimensions
- Wire onLoadSuccess callback on Page to capture originalWidth/Height using Math.max mediaBox pattern
- Import and wrap Document/Page tree inside FieldPlacer component
- Pass docId, pageInfo, currentPage to FieldPlacer for coordinate conversion
- Only scale prop used on Page (not both width+scale — avoids double scaling)
- All existing controls (Prev, Next, Zoom In/Out, Download) preserved unchanged
2026-03-20 00:00:22 -06:00
Chandler Copeland
6069ae5e06 feat(05-02): install dnd-kit and create FieldPlacer component
- Install @dnd-kit/core@^6.3.1 and @dnd-kit/utilities@^3.2.2
- Create FieldPlacer.tsx with DndContext, draggable palette token, droppable PDF zone
- Implements Y-flip coordinate conversion (screenToPdfCoords / pdfToScreenCoords)
- Fetches existing fields from GET /api/documents/[id]/fields on mount
- Persists fields via PUT /api/documents/[id]/fields on every add/remove
- Renders placed fields as absolute-positioned blue-bordered overlays with remove button
- Default field size: 144x36 PDF points (2in x 0.5in at 72 DPI)
2026-03-19 23:59:51 -06:00
Chandler Copeland
f1cb526213 docs(05-01): complete pdf-fill-and-field-mapping plan 01
- Created 05-01-SUMMARY.md documenting all tasks, decisions, and deviations
- Updated STATE.md: advanced to Phase 5 Plan 1 complete, added 6 new decisions
- Updated ROADMAP.md: marked 05-01-PLAN.md complete, Phase 5 progress 1/4
- Marked requirements DOC-04, DOC-05, DOC-06 as complete in REQUIREMENTS.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 23:57:34 -06:00
Chandler Copeland
34ed0baa43 test(05-01): add unit tests for Y-flip coordinate conversion formula
- Created src/lib/pdf/__tests__/prepare-document.test.ts with 10 test cases
- Tests verify Y-axis flip: screenY=0 → pdfY≈792, screenY=792 → pdfY≈0
- Tests verify scale-invariance at both 1:1 and 50% zoom ratios
- Installed jest, ts-jest, @types/jest and added jest config to package.json
- All 10 tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 23:55:27 -06:00
Chandler Copeland
c81e8ea838 feat(05-01): add preparePdf utility and fields/prepare API routes
- Installed @cantoo/pdf-lib for server-side PDF mutation
- Created src/lib/pdf/prepare-document.ts with preparePdf function using atomic tmp->rename write pattern
- form.flatten() called before drawing signature rectangles
- Created GET/PUT /api/documents/[id]/fields routes for signature field storage
- Created POST /api/documents/[id]/prepare route that calls preparePdf and transitions status to Sent
- Fixed pre-existing null check error in scripts/debug-inspect2.ts (Rule 3: blocking build)
- Build compiles successfully with 2 new API routes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 23:54:41 -06:00
Chandler Copeland
d67130da20 feat(05-01): extend documents schema with 4 new columns + migration 0003
- Added SignatureFieldData interface export to schema.ts
- Added signatureFields (jsonb), textFillData (jsonb), assignedClientId (text), preparedFilePath (text) nullable columns to documents table
- Added jsonb import to drizzle-orm/pg-core imports
- Generated and applied migration 0003_cool_natasha_romanoff.sql

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 23:53:12 -06:00
Chandler Copeland
a997ebda20 fix(05): revise plan 05-01 based on checker feedback 2026-03-19 23:48:58 -06:00
Chandler Copeland
ceaae6eec5 docs(05-pdf-fill-and-field-mapping): create phase plan 2026-03-19 23:44:23 -06:00
Chandler Copeland
bec29f80b1 docs(05): research phase PDF fill and field mapping 2026-03-19 23:36:47 -06:00
Chandler Copeland
ac5b98fe33 wip: skyslope scraper — fix name extraction via body text parsing, preview+download flow ready 2026-03-19 23:06:17 -06:00
Chandler Copeland
1983f2c8cd wip: pause before phase 5 planning — skyslope scraper in progress 2026-03-19 22:57:14 -06:00
Chandler Copeland
27462a0ebb feat: add Playwright script to scrape SkySlope form libraries into seeds/forms/ 2026-03-19 22:27:41 -06:00
Chandler Copeland
ebb0bf03b7 docs(phase-04): complete phase execution 2026-03-19 22:13:15 -06:00
Chandler Copeland
9e89c3aeb5 docs(04-04): complete Phase 4 PDF ingest human verification — approved
- Human agent confirmed all 7 browser verification steps pass
- Forms library, modal, PDF render, file storage, and auth guards verified
- Phase 4 declared complete
- STATE.md updated: phase 4/4 complete, progress 100%
- ROADMAP.md updated: phase 4 all 4 plans complete

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 22:06:25 -06:00
Chandler Copeland
6c5e4afd86 fix(04-03): move ssr:false dynamic import into client wrapper to fix DOMMatrix SSR error 2026-03-19 22:01:58 -06:00
Chandler Copeland
025d9896ed fix(04-03): make back button more prominent with bordered pill style 2026-03-19 21:56:36 -06:00
Chandler Copeland
5c7a0fd061 fix(04-03): style Browse files as a visible button with selected filename display 2026-03-19 21:54:07 -06:00
Chandler Copeland
7ddc690482 docs(04-03): complete PDF viewer UI plan summary
- SUMMARY: AddDocumentModal, PdfViewer, /portal/documents/[docId] page
- STATE: current position updated to 04-03 complete, 3/4 plans in phase
- ROADMAP: phase 4 progress updated (3 summaries of 4 plans)
- REQUIREMENTS: DOC-03 marked complete
2026-03-19 21:47:09 -06:00
Chandler Copeland
c1f60cadf6 feat(04-03): add AddDocumentModal, PdfViewer, and document detail page
- Create AddDocumentModal: searchable forms library list + custom file picker
- Wire Add Document button into ClientProfileClient in Documents section header
- Update DocumentsTable: document names now link to /portal/documents/{id}
- Create PdfViewer with page nav, zoom, and download controls (pdfjs worker via import.meta.url)
- Create /portal/documents/[docId] page: server component with auth check, doc/client query
- Add documentsRelations and clientsRelations to schema.ts for db.query with-relations support
- Build verified: /portal/documents/[docId] route present, no errors
2026-03-19 21:44:17 -06:00
Chandler Copeland
63e5888968 feat(04-03): install react-pdf and configure Next.js transpilePackages
- npm install react-pdf (v9+ pulls in pdfjs-dist automatically)
- Add transpilePackages: ['react-pdf', 'pdfjs-dist'] to next.config.ts
- Build verified passing after config change
2026-03-19 21:42:06 -06:00
Chandler Copeland
7ddb920467 docs(04-02): complete PDF API routes plan summary
- Created 04-02-SUMMARY.md with task commits, decisions, and dependency graph
- Updated STATE.md: position advanced to 04-02 complete, decisions added
- Updated ROADMAP.md: phase 4 progress to 2/4 plans
2026-03-19 21:38:37 -06:00
Chandler Copeland
32e129c097 feat(04-02): create POST /api/documents and GET /api/documents/[id]/file routes
- POST handles both form-data (custom upload) and JSON (template copy) paths
- Copies seed PDF or writes uploaded file to uploads/clients/{clientId}/{uuid}.pdf
- Path traversal guard on destPath before writing
- GET streams PDF bytes with Content-Type: application/pdf
- Path traversal guard on filePath before reading
- Both routes return 401 for unauthenticated requests
2026-03-19 21:36:54 -06:00
Chandler Copeland
e0f180c3d8 feat(04-02): create GET /api/forms-library authenticated template list
- Queries form_templates ordered by name (asc)
- Returns 401 for unauthenticated requests
- Returns JSON array of { id, name, filename } for authenticated agents
2026-03-19 21:36:21 -06:00
Chandler Copeland
c830951afe docs(04-01): complete PDF ingest data layer plan summary
- Create 04-01-SUMMARY.md: form_templates schema + seed:forms CLI
- Update STATE.md: position advanced to Phase 4 Plan 1 complete
- Update ROADMAP.md: Phase 04 plan progress (1/4 complete)
- Mark requirements DOC-01, DOC-02 complete in REQUIREMENTS.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 21:34:51 -06:00
Chandler Copeland
f82364d2c7 feat(04-01): create seed-forms script and npm run seed:forms command
- Create scripts/seed-forms.ts: reads seeds/forms/, upserts PDFs into form_templates via onConflictDoUpdate on filename
- Add seed:forms script to package.json with DOTENV_CONFIG_PATH=.env.local prefix
- Empty seeds/forms/ prints guidance message and exits 0 (monthly-sync workflow ready)
2026-03-19 21:33:02 -06:00
Chandler Copeland
bbbbdbed5e feat(04-01): add formTemplates table and extend documents schema
- Add formTemplates table (id text PK, name, filename unique, createdAt, updatedAt)
- Add formTemplateId (nullable FK) and filePath (nullable text) to documents table
- Generate and apply migration 0002_wealthy_zzzax.sql
- Create seeds/forms/.gitkeep to track seed directory in git
2026-03-19 21:32:30 -06:00
Chandler Copeland
c896fa5e82 docs(04-pdf-ingest): create phase 4 plan (4 plans, 4 waves)
Plans 04-01 through 04-04 cover DOC-01, DOC-02, DOC-03:
schema/seed, API routes, UI modal + PDF viewer, human verification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 21:28:39 -06:00
Chandler Copeland
521646f312 docs(04): research phase PDF ingest domain 2026-03-19 21:24:01 -06:00
Chandler Copeland
5fc9ccc6c8 docs(04): capture phase context 2026-03-19 21:20:10 -06:00
Chandler Copeland
dc076cf309 docs(phase-3): complete phase execution and verification 2026-03-19 17:53:40 -06:00
Chandler Copeland
7a19a10a0c docs(03-04): complete client profile page and Phase 3 portal verification summary 2026-03-19 17:34:55 -06:00
Chandler Copeland
b186ac5f38 feat(03-04): add client profile page with edit/delete and documents table
- Create ConfirmDialog component with overlay, title, message, cancel/confirm buttons
- Create ClientProfilePage server component (awaits params Promise — Next.js 16)
- Create ClientProfileClient client component with edit modal and delete confirmation
- Documents section uses DocumentsTable with showClientColumn={false}
- deleteClient called directly from async event handler in client component
2026-03-19 16:58:21 -06:00
Chandler Copeland
b94720bde8 docs(03-03): complete dashboard and clients plan summary 2026-03-19 16:54:35 -06:00
Chandler Copeland
3fa2e1c424 feat(03-03): extend seed.ts with client and placeholder document rows
- Added import of clients, documents, inArray from drizzle-orm
- Seeds 2 clients: Sarah Johnson and Mike Torres (onConflictDoNothing)
- Queries back seeded client IDs, then seeds 4 placeholder documents
- Documents cover Signed/Sent/Draft statuses across both clients
- Seed is idempotent via onConflictDoNothing guard
2026-03-19 16:49:29 -06:00
Chandler Copeland
df1924acc4 feat(03-03): add Clients page with card grid and create modal
- ClientCard.tsx: server component with name, email, doc count, last activity; wrapped in Link to /portal/clients/[id]
- ClientModal.tsx: use client component with useActionState from react; supports create/edit modes via bind pattern; closes on success
- ClientsPageClient.tsx: use client wrapper holding isOpen modal state, renders card grid or empty state CTA
- clients/page.tsx: async server component fetching clients with docCount + lastActivity via Drizzle LEFT JOIN + GROUP BY
2026-03-19 16:47:28 -06:00
Chandler Copeland
e55d7a1de5 feat(03-03): add Dashboard page with filterable documents table
- Async server component queries all documents with LEFT JOIN to clients
- Filter state lives in URL (?status=Draft|Sent|Viewed|Signed) via DashboardFilters client component
- Rows filtered in JavaScript after fetch (tiny dataset in Phase 3)
- DashboardFilters extracted to _components/DashboardFilters.tsx (use client + useRouter)
- Displays agent first name extracted from session email
2026-03-19 16:46:26 -06:00
Chandler Copeland
59acc62606 docs(03-02): complete portal shell plan — layout, nav, components, client actions
- 03-02-SUMMARY.md: plan summary with task commits, deviations, and decisions
- STATE.md: updated current position to Phase 3 Plan 02 complete, added decisions
- ROADMAP.md: Phase 3 progress updated (2/4 plans complete)
2026-03-19 16:43:37 -06:00
Chandler Copeland
5b87201b28 feat(03-02): add createClient, updateClient, deleteClient server actions
- 'use server' file with Zod validation (name min 1 char, valid email)
- createClient: validate, insert, revalidatePath /portal/clients
- updateClient: bind pattern (id, prevState, formData), revalidates client list + profile
- deleteClient: auth check, delete by id, revalidatePath /portal/clients
- Fixed Zod v4 .issues access (not .errors — v4 API change)
2026-03-19 16:38:49 -06:00
Chandler Copeland
28d42f5d9b feat(03-02): add StatusBadge and DocumentsTable shared portal components
- StatusBadge: color-coded pill for Draft=gray, Sent=blue, Viewed=amber, Signed=green
- DocumentsTable: reusable table with optional Client column, StatusBadge integration
- Date format: toLocaleDateString en-US short month; null sentAt renders as em-dash
2026-03-19 16:37:30 -06:00
Chandler Copeland
9c4caeedba feat(03-02): add portal authenticated layout and PortalNav
- Create portal/(protected)/layout.tsx with auth() check and redirect to /agent/login
- Create PortalNav.tsx as client component with Dashboard/Clients links and active state
- Nav uses usePathname() for active gold underline, LogoutButton for sign-out
- CSS variables --navy/--gold/--cream applied throughout portal shell
2026-03-19 16:37:03 -06:00
Chandler Copeland
00f9c7c9f0 feat(03-01): protect /portal routes and update post-login redirect
- middleware.ts: add /portal/:path* to matcher array
- auth.config.ts: add isPortalRoute check, redirect unauthenticated to /agent/login
- auth.config.ts: change post-login redirect from /agent/dashboard to /portal/dashboard
- agent dashboard page: replace stub with redirect to /portal/dashboard
2026-03-19 16:17:59 -06:00
Chandler Copeland
f8f8b8f4ba feat(03-01): add clients and documents tables to Drizzle schema
- Add pgEnum import and documentStatusEnum (Draft, Sent, Viewed, Signed)
- Add clients table (id, name, email, createdAt, updatedAt)
- Add documents table (id, name, clientId FK, status enum, sentAt, createdAt)
- Generate migration 0001_watery_blindfold.sql and apply to local PostgreSQL
2026-03-19 16:17:26 -06:00
Chandler Copeland
3cda82df51 docs(03-agent-portal-shell): create phase 3 plan — 4 plans in 4 waves 2026-03-19 16:13:10 -06:00
Chandler Copeland
d4fd2bcdc8 docs(03): research phase agent-portal-shell 2026-03-19 16:04:17 -06:00
Chandler Copeland
c6cd488fa3 docs(03): capture phase context 2026-03-19 15:59:08 -06:00
Chandler Copeland
4d9c74a1e3 docs(phase-02): complete phase execution 2026-03-19 15:27:47 -06:00
Chandler Copeland
9500f812e0 docs(02-03): complete human verification — phase 2 approved
- All 7 checklist items approved by human reviewer
- Visual fixes applied: hero objectPosition 20%, contact form white inputs, testimonial gold accent bar
- Phase 2 marketing site marked complete (MKTG-01 through MKTG-04 satisfied)
- STATE.md updated: phase 2 complete, 6/6 plans done, progress 40%
2026-03-19 15:19:22 -06:00
Chandler Copeland
5842ffc9f3 docs(02-02): complete contact form plan — SUMMARY, STATE, plans tracked
- Create 02-02-SUMMARY.md: contact form outcomes, decisions, deviations
- Update STATE.md: position, decisions (nodemailer v7 pin, useActionState React 19, honeypot pattern)
- Add 02-01-PLAN.md, 02-02-PLAN.md, 02-03-PLAN.md to version control
- Mark MKTG-03 requirement complete

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 15:04:45 -06:00
Chandler Copeland
ffb1ab629d docs(02-01): complete marketing site shell plan — nav, hero, testimonials, footer
- Create 02-01-SUMMARY.md with execution results and deviation docs
- Update STATE.md position and session continuity
- Update ROADMAP.md phase 02 progress
- Mark MKTG-01, MKTG-02, MKTG-04 requirements complete
2026-03-19 15:04:15 -06:00