'use client'; import { Loader2, CheckCircle, X } from 'lucide-react'; import { useRegisterModal } from './modal/ModalStackProvider'; import { useEffect, useRef } from 'react'; import { Button } from './ui/button'; interface LoadingModalProps { isOpen: boolean; action: string; logs?: string[]; isComplete?: boolean; title?: string; onClose?: () => void; } export function LoadingModal({ isOpen, action, logs = [], isComplete = false, title, onClose }: LoadingModalProps) { // Allow dismissing with ESC only when complete, prevent during running useRegisterModal(isOpen, { id: 'loading-modal', allowEscape: isComplete, onClose: onClose || (() => null) }); const logsEndRef = useRef(null); // Auto-scroll to bottom when new logs arrive useEffect(() => { logsEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [logs]); if (!isOpen) return null; return (
{/* Close button - only show when complete */} {isComplete && onClose && ( )}
{isComplete ? ( ) : ( <>
)}
{/* Static title text */} {title && (

{title}

)} {/* Log output */} {logs.length > 0 && (
{logs.map((log, index) => (
{log}
))}
)} {!isComplete && (
)}
); }