import { useEffect, useState } from 'react'; import { X, Download, Loader2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import type { ExportProgress } from '@/lib/exporter'; interface ExportDialogProps { isOpen: boolean; onClose: () => void; progress: ExportProgress | null; isExporting: boolean; error: string | null; onCancel?: () => void; } export function ExportDialog({ isOpen, onClose, progress, isExporting, error, onCancel, }: ExportDialogProps) { const [showSuccess, setShowSuccess] = useState(false); useEffect(() => { if (!isExporting && progress && progress.percentage >= 100 && !error) { setShowSuccess(true); const timer = setTimeout(() => { setShowSuccess(false); onClose(); }, 2000); return () => clearTimeout(timer); } }, [isExporting, progress, error, onClose]); if (!isOpen) return null; return ( <>
{showSuccess ? ( <>
Export Complete Your video is ready
) : ( <> {isExporting ? (
) : (
)}
{error ? 'Export Failed' : isExporting ? 'Exporting Video' : 'Export Video'} {error ? 'Please try again' : isExporting ? 'This may take a moment...' : 'Ready to start'}
)}
{!isExporting && ( )}
{error && (

{error}

)} {isExporting && progress && (
Progress {progress.percentage.toFixed(0)}%
Current Frame
{progress.currentFrame} / {progress.totalFrames}
Status
Processing
{onCancel && (
)}
)} {showSuccess && (

Video saved successfully!

)}
); }