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 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 // Load version data
const { rows } = await pool.query( const { rows } = await pool.query(
`SELECT table_name, data FROM pitch_version_data WHERE version_id = $1`, `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) { 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[]> = {} 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 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({ return NextResponse.json({
company: (map.company || [])[0] || null, company: (map.company || [])[0] || null,
team: map.team || [], team: map.team || [],
@@ -40,5 +49,6 @@ export async function GET(request: NextRequest, ctx: Ctx) {
metrics: map.metrics || [], metrics: map.metrics || [],
funding: (map.funding || [])[0] || null, funding: (map.funding || [])[0] || null,
products: map.products || [], 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() { export default function PreviewPage() {
const { versionId } = useParams<{ versionId: string }>() const { versionId } = useParams<{ versionId: string }>()
const [data, setData] = useState<PitchData | null>(null) const [data, setData] = useState<PitchData | null>(null)
const [versionMeta, setVersionMeta] = useState<{ name: string; status: string } | null>(null)
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null) const [error, setError] = useState<string | null>(null)
const [lang, setLang] = useState<Language>('de') 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') if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || 'Failed to load')
return r.json() return r.json()
}) })
.then(setData) .then(d => {
if (d._version) {
setVersionMeta(d._version)
delete d._version
}
setData(d)
})
.catch(e => setError(e.message)) .catch(e => setError(e.message))
.finally(() => setLoading(false)) .finally(() => setLoading(false))
}, [versionId]) }, [versionId])
@@ -57,8 +64,8 @@ export default function PreviewPage() {
return ( return (
<div className="relative"> <div className="relative">
{/* Preview banner */} {/* 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"> <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 MODE This is how investors will see this version PREVIEW: {versionMeta?.name ?? 'Loading...'} {versionMeta?.status === 'draft' ? 'Draft' : 'Committed'}
</div> </div>
<PitchDeck <PitchDeck
lang={lang} lang={lang}