import React, { useState, useEffect } from 'react'; import { Loader2, LucideIcon } from 'lucide-react'; import { cn } from '@/lib/utils'; import { Progress } from '@/components/ui/progress'; interface LoadingStateProps { icon?: LucideIcon; iconColor?: string; bgColor?: string; title: string; subtitle?: string; filePath?: string | null; showProgress?: boolean; progressText?: string; autoProgress?: boolean; initialProgress?: number; } export function LoadingState({ icon: Icon = Loader2, iconColor = 'text-purple-500 dark:text-purple-400', bgColor = 'bg-gradient-to-b from-purple-100 to-purple-50 shadow-inner dark:from-purple-800/40 dark:to-purple-900/60 dark:shadow-purple-950/20', title, subtitle, filePath, showProgress = true, progressText, autoProgress = true, initialProgress = 0, }: LoadingStateProps): JSX.Element { const [progress, setProgress] = useState(initialProgress); useEffect(() => { if (showProgress && autoProgress) { setProgress(0); const timer = setInterval(() => { setProgress((prevProgress) => { if (prevProgress >= 95) { clearInterval(timer); return prevProgress; } return prevProgress + Math.random() * 10 + 5; }); }, 500); return () => clearInterval(timer); } }, [showProgress, autoProgress]); return (

{title}

{filePath && (
{filePath}
)} {showProgress && (
{progressText || 'Processing...'} {Math.round(Math.min(progress, 100))}%
)} {subtitle && (

{subtitle}

)}
); }