"use client"; import { Dialog, DialogClose, DialogContent, DialogTitle, } from "@prototype/components/ui/dialog"; import { PROTOTYPE_TOOL_MODAL_CLOSE_CLASS } from "@prototype/components/platform-ui/prototype-tool-dialog"; import { useTrackEvent } from "@prototype/lib/prototypes/telemetry/prototype-telemetry-context"; import { ExternalLink, Loader2, X } from "lucide-react"; import { useEffect, useState } from "react"; const MODAL_CHROME_BUTTON_CLASS = PROTOTYPE_TOOL_MODAL_CLOSE_CLASS; export type PrototypeVercelPreviewModalProps = { open: boolean; onOpenChange: (open: boolean) => void; title: string; previewUrl: string | null; inspectorUrl?: string | null; loading?: boolean; error?: string | null; }; export function PrototypeVercelPreviewModal({ open, onOpenChange, title, previewUrl, inspectorUrl, loading = false, error = null, }: PrototypeVercelPreviewModalProps) { const [iframeLoaded, setIframeLoaded] = useState(false); const track = useTrackEvent(); useEffect(() => { if (!open) { setIframeLoaded(false); } }, [open, previewUrl]); useEffect(() => { if (open) { track("vercel_preview.opened", { title }); } }, [open, title, track]); const showIframe = Boolean(previewUrl) && !loading && !error; return (
{title}
{previewUrl ? ( ) : null} {inspectorUrl ? ( Vercel ) : null} Close
{loading ? (
Loading preview…
) : null} {!loading && error ? (
{error}
) : null} {showIframe ? ( <> {!iframeLoaded ? (
Loading deployment…
) : null}