feat: email capture on catalog valuation report
What
Adds an "Email me this report" capture to the public catalog valuation report page (/catalogs/[catalogId]), which previously captured nothing. Part of recoupable/chat#1902 (item C3).
components/Catalog/report/CatalogReportEmailCapture.tsx- email input + submit card in the report house style (shadow-as-border, achromatic). Success state replaces the form: "Report sent. Check your inbox."app/api/catalogs/[catalogId]/email-report/route.ts- new deliberately unauthenticated POST route so ANONYMOUS viewers can use it. Validates the catalog id (uuid) and body (zod: email + optionalheadline_value), then sends via the chat repo's existing Resend path (lib/email/sendEmailfromRECOUP_FROM_EMAIL). The viewer's email is used for the send only and is never logged.lib/catalog/emailReport/-validateEmailReportBody(zod),renderReportEmailHtml(headline value + report link button),sendCatalogReportEmail(subject carries the formatted value, e.g. "Your catalog valuation report: $1.4M"). One exported function per file.CatalogReportContent.tsx- mounts the capture directly under the valuation card (capture alongside the number, never in front - the valuation stays fully ungated per the recorded architecture decision), and also on the no-measurements state, since anonymous viewers currently land there (the measurements query requires Privy auth).
Why an api-side endpoint was not used
Checked the api submodule first: POST /api/emails is account-scoped (x-api-key, recipients restricted to the account's own email without a card on file) and api#773's valuation-report email only sends to the owning account on valuation complete. Neither fits an anonymous viewer typing an arbitrary address, so this ships as a thin chat-side route on the chat repo's own Resend integration.
How to test
- Open a preview deployment at
/catalogs/<catalogId>(works logged out). - The "Email me this report" card renders under the valuation card (or under the error card when logged out).
- Submit a valid email: card flips to "Report sent. Check your inbox." and the email arrives from
agent@recoupable.devwith the headline value in the subject and a button back to the report. - Deliberate 4xx probes:
POST /api/catalogs/not-a-uuid/email-reportreturns 400; body{"email":"nope"}returns 400; malformed JSON returns 400; a Resend failure returns 502.
Tests: pnpm exec vitest run lib/catalog/emailReport "app/api/catalogs/[catalogId]/email-report" - 4 files, 20 tests passing (validation, HTML render, send wiring, route status codes). pnpm exec tsc --noEmit clean for all files in this PR (remaining errors are the pre-existing lib/emails/__tests__ baseline).
Preview verification to follow in a PR comment.
Part of recoupable/chat#1902
🤖 Generated with Claude Code
Summary by cubic
Adds “Email me this report” to the public catalog valuation page so anonymous viewers can email themselves the report link and headline value. Supports recoupable/chat#1902 (C3) by enabling ungated report sharing without login.
- New Features
- Email capture card under the valuation (and on the no-measurements state); success state shows “Report sent. Check your inbox.”
- New unauthenticated POST
POST /api/catalogs/[catalogId]/email-reportwithzodvalidation (UUID catalog id, email, optionalheadline_value); sends via the repo’sResendpath fromRECOUP_FROM_EMAILand never logs the viewer’s email. - Email subject includes the formatted value when provided; HTML body includes the value and a button back to the report.
- Tests cover body validation, HTML rendering, send wiring, and route status codes.