'use client' import { useEffect, useState, useCallback } from 'react' import { useParams } from 'next/navigation' import { Language, PitchData } from '@/lib/types' import PitchDeck from '@/components/PitchDeck' export default function PreviewPage() { const { versionId } = useParams<{ versionId: string }>() const [data, setData] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [lang, setLang] = useState('de') const toggleLanguage = useCallback(() => { setLang(prev => prev === 'de' ? 'en' : 'de') }, []) useEffect(() => { if (!versionId) return setLoading(true) fetch(`/api/preview-data/${versionId}`) .then(async r => { if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || 'Failed to load') return r.json() }) .then(setData) .catch(e => setError(e.message)) .finally(() => setLoading(false)) }, [versionId]) if (loading) { return (

Loading preview...

) } if (error || !data) { return (

Preview Error

{error || 'No data found for this version'}

Make sure you are logged in as an admin.

) } // Render PitchDeck with no investor (no watermark, no audit) — admin preview only // The banner at the top indicates this is a preview return (
{/* Preview banner */}
PREVIEW MODE — This is how investors will see this version
{}} previewData={data} />
) }