'use client' import { useEffect, useState, useRef } from 'react' import { FileText, Download, Upload, Eye, LogOut } from 'lucide-react' interface Doc { id: string filename: string display_name: string | null mime_type: string file_size: number released_at: string } interface MyUpload { id: string filename: string display_name: string | null mime_type: string file_size: number created_at: string } function fmt(bytes: number) { if (bytes < 1024) return `${bytes} B` if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB` return `${(bytes / (1024 * 1024)).toFixed(1)} MB` } function isPDF(mime: string) { return mime === 'application/pdf' } export default function DataroomPage() { const [docs, setDocs] = useState([]) const [uploads, setUploads] = useState([]) const [uploading, setUploading] = useState(false) const [toast, setToast] = useState(null) const fileRef = useRef(null) function flash(msg: string) { setToast(msg) setTimeout(() => setToast(null), 3500) } async function loadAll() { const [dr, ur] = await Promise.all([ fetch('/api/dataroom/documents'), fetch('/api/dataroom/uploads'), ]) if (dr.ok) setDocs((await dr.json()).documents) if (ur.ok) setUploads((await ur.json()).uploads) } useEffect(() => { loadAll() }, []) async function handleUpload(e: React.ChangeEvent) { const file = e.target.files?.[0] if (!file) return setUploading(true) const fd = new FormData() fd.append('file', file) const r = await fetch('/api/dataroom/uploads', { method: 'POST', body: fd }) setUploading(false) if (r.ok) { flash('File uploaded successfully'); loadAll() } else { const d = await r.json().catch(() => ({})) flash(d.error || 'Upload failed') } e.target.value = '' } return (
{/* Header */}

Data Room

BreakPilot ComplAI · Investor Portal

{/* Released documents */}

Documents

{docs.length === 0 ? (

No documents have been shared with you yet.

) : (
{docs.map(doc => (
{doc.display_name || doc.filename}
{fmt(doc.file_size)} · Released {new Date(doc.released_at).toLocaleDateString()}
{isPDF(doc.mime_type) && ( Preview )} Download
))}
)}
{/* Upload section */}

Your Documents

Upload documents you want to share with us — NDAs, term sheets, financial statements, or any other relevant files.

{uploads.length === 0 ? (

No files uploaded yet.

) : (
{uploads.map(u => (
{u.display_name || u.filename}
{fmt(u.file_size)} · {new Date(u.created_at).toLocaleString()}
Received
))}
)}
{toast && (
{toast}
)}
) }