'use client'; import { useState } from 'react'; import BlurOverlay from './BlurOverlay'; import EditableOutput from './EditableOutput'; import ExportMenu from './ExportMenu'; type State = 'idle' | 'generating' | 'preview' | 'unlocked' | 'done'; interface OutputPanelProps { tool: string; sessionId: string | null; preview: string | null; fullOutput: string | null; isPaid: boolean; generating?: boolean; onPaymentRequest: () => void; paymentLoading?: boolean; } export default function OutputPanel({ tool, sessionId, preview, fullOutput, isPaid, generating, onPaymentRequest, paymentLoading, }: OutputPanelProps) { const [output, setOutput] = useState(fullOutput); const [finalizing, setFinalizing] = useState(false); const state: State = generating ? 'generating' : !sessionId ? 'idle' : !preview ? 'idle' : !isPaid ? 'preview' : finalizing ? 'done' : 'unlocked'; const displayOutput = output || fullOutput; const handleFinalize = async () => { setFinalizing(true); try { const res = await fetch(`/api/${tool}/finalize`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ session_id: sessionId }), }); const data = await res.json(); if (data.finalized) setOutput(data.finalized); } catch (e) { console.error('Finalize failed:', e); } }; if (state === 'idle') { return (
Fill in the form and click Generate to get started
Generating your output...
This may take 15-30 seconds