Skip to content

Preview shows the agreement as drafted, and saves it as a PDF - #4

Merged
tbrooke merged 1 commit into
trustblocksfrom
fix/preview-drawer
Sep 28, 2026
Merged

tbrooke merged 1 commit into
trustblocksfrom
fix/preview-drawer

Conversation

@tbrooke

@tbrooke tbrooke commented Sep 28, 2026

Copy link
Copy Markdown

The Preview button on the Text and Data steps opened a drawer with an empty page, and its ↓ PDF button did nothing. Upstream's design-v2 left both as placeholders: the drawer body was an empty <div className="nd-preview-page" />.

Now:

  • The drawer shows the agreement as drafted. That's the store's agreementHtml: the text, model and data merged, and rebuilt on every edit, so the preview is live. It's sanitized with DOMPurify, as the legacy layout's preview is.
  • When the template can't be drafted, the drawer says why, instead of showing a stale page. The PDF button is disabled then.
  • PDF saves the page as agreement.pdf (A4), the same way the legacy layout's download does. html2pdf is loaded on first use.

Tests:

  • Unit: 313 of 313 pass. PreviewDrawer.test.tsx covers its three states:
    • drafted, with a script-carrying tag stripped;
    • not drafted, showing the reason, with PDF disabled;
    • drafting.
  • e2e: 5 of 5 pass. The new test opens the pay request's preview, reads CONTRACTOR PAY REQUEST and PROJECT: STR-27, and downloads agreement.pdf.

This is independent of #3; either can merge first.

🤖 Generated with Claude Code

Design v2's preview drawer (the Preview button on the Text and Data steps)
opened onto an empty page, and its PDF button did nothing: upstream left
both as placeholders. It now shows the store's agreementHtml -- the text,
model and data drafted, rebuilt on every edit, sanitized as the legacy
layout's preview is -- or, while the template does not draft, why not; and
PDF saves that page (html2pdf, loaded on first use), as the legacy
layout's download does.

Tests: PreviewDrawer's three states (drafted and sanitized, not drafted
with the reason and no PDF, drafting); e2e opens the pay request's preview
and downloads agreement.pdf.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tbrooke
tbrooke merged commit d0ec8af into trustblocks Sep 28, 2026
2 checks passed
@tbrooke
tbrooke deleted the fix/preview-drawer branch September 28, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant