import { useState } from 'react'; import { Loader2, ExternalLink, RefreshCw, Terminal } from 'lucide-react'; interface SandboxPreviewProps { type: 'vite' | 'nextjs' | 'console'; output?: string; isLoading?: boolean; sandboxUrl?: string; // Real URL from Vercel Sandbox API } export default function SandboxPreview({ type, output, isLoading = false, sandboxUrl }: SandboxPreviewProps) { const [showConsole, setShowConsole] = useState(false); const [iframeKey, setIframeKey] = useState(0); // Use the real sandbox URL passed from the API const previewUrl = sandboxUrl || ''; const handleRefresh = () => { setIframeKey(prev => prev + 1); }; if (type === 'console') { return (
{previewUrl}
) : (
Waiting for sandbox URL...
)}
{!previewUrl ? 'Setting up sandbox environment...' : type === 'vite' ? 'Starting Vite dev server...' : 'Starting Next.js dev server...' }