From c02a7bd8a68b9f53f51d7691556af6f74d6f9e82 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Mon, 13 Apr 2026 12:21:59 +0200 Subject: [PATCH] feat(pitch-deck): show version name + status in preview banner Co-Authored-By: Claude Opus 4.6 (1M context) --- .../app/api/preview-data/[versionId]/route.ts | 14 ++++++++++++-- pitch-deck/app/pitch-preview/[versionId]/page.tsx | 13 ++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pitch-deck/app/api/preview-data/[versionId]/route.ts b/pitch-deck/app/api/preview-data/[versionId]/route.ts index 6b6d3e8..c8762ce 100644 --- a/pitch-deck/app/api/preview-data/[versionId]/route.ts +++ b/pitch-deck/app/api/preview-data/[versionId]/route.ts @@ -13,6 +13,15 @@ export async function GET(request: NextRequest, ctx: Ctx) { const { versionId } = await ctx.params + // Load version metadata + const ver = await pool.query( + `SELECT name, status FROM pitch_versions WHERE id = $1`, + [versionId], + ) + if (ver.rows.length === 0) { + return NextResponse.json({ error: 'Version not found' }, { status: 404 }) + } + // Load version data const { rows } = await pool.query( `SELECT table_name, data FROM pitch_version_data WHERE version_id = $1`, @@ -20,7 +29,7 @@ export async function GET(request: NextRequest, ctx: Ctx) { ) if (rows.length === 0) { - return NextResponse.json({ error: 'Version not found or has no data' }, { status: 404 }) + return NextResponse.json({ error: 'Version has no data' }, { status: 404 }) } const map: Record = {} @@ -28,7 +37,7 @@ export async function GET(request: NextRequest, ctx: Ctx) { map[row.table_name] = typeof row.data === 'string' ? JSON.parse(row.data) : row.data } - // Return PitchData format + // Return PitchData format + version metadata return NextResponse.json({ company: (map.company || [])[0] || null, team: map.team || [], @@ -40,5 +49,6 @@ export async function GET(request: NextRequest, ctx: Ctx) { metrics: map.metrics || [], funding: (map.funding || [])[0] || null, products: map.products || [], + _version: { name: ver.rows[0].name, status: ver.rows[0].status }, }) } diff --git a/pitch-deck/app/pitch-preview/[versionId]/page.tsx b/pitch-deck/app/pitch-preview/[versionId]/page.tsx index 2487efe..407bb89 100644 --- a/pitch-deck/app/pitch-preview/[versionId]/page.tsx +++ b/pitch-deck/app/pitch-preview/[versionId]/page.tsx @@ -8,6 +8,7 @@ import PitchDeck from '@/components/PitchDeck' export default function PreviewPage() { const { versionId } = useParams<{ versionId: string }>() const [data, setData] = useState(null) + const [versionMeta, setVersionMeta] = useState<{ name: string; status: string } | null>(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [lang, setLang] = useState('de') @@ -24,7 +25,13 @@ export default function PreviewPage() { if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || 'Failed to load') return r.json() }) - .then(setData) + .then(d => { + if (d._version) { + setVersionMeta(d._version) + delete d._version + } + setData(d) + }) .catch(e => setError(e.message)) .finally(() => setLoading(false)) }, [versionId]) @@ -57,8 +64,8 @@ export default function PreviewPage() { return (
{/* Preview banner */} -
- PREVIEW MODE — This is how investors will see this version +
+ PREVIEW: {versionMeta?.name ?? 'Loading...'} — {versionMeta?.status === 'draft' ? 'Draft' : 'Committed'}