feat(pitch-deck): show version name + status in preview banner

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-04-13 12:21:59 +02:00
parent b6d3fad6ab
commit c02a7bd8a6
2 changed files with 22 additions and 5 deletions

View File

@@ -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<string, unknown[]> = {}
@@ -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 },
})
}

View File

@@ -8,6 +8,7 @@ import PitchDeck from '@/components/PitchDeck'
export default function PreviewPage() {
const { versionId } = useParams<{ versionId: string }>()
const [data, setData] = useState<PitchData | null>(null)
const [versionMeta, setVersionMeta] = useState<{ name: string; status: string } | null>(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
const [lang, setLang] = useState<Language>('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 (
<div className="relative">
{/* Preview banner */}
<div className="fixed top-0 left-0 right-0 z-[100] bg-amber-500/90 text-black text-center py-1.5 text-xs font-semibold">
PREVIEW MODE This is how investors will see this version
<div className="fixed top-0 left-0 right-0 z-[100] bg-amber-500/90 text-black text-center py-1.5 text-xs font-semibold tracking-wide">
PREVIEW: {versionMeta?.name ?? 'Loading...'} {versionMeta?.status === 'draft' ? 'Draft' : 'Committed'}
</div>
<PitchDeck
lang={lang}