import React, { useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; interface LoadingSectionProps { onComplete?: () => void; isComplete?: boolean; } const LoadingSection: React.FC = ({ onComplete, isComplete }) => { const { t } = useTranslation(); const [progress, setProgress] = useState(0); const intervalRef = useRef | null>(null); useEffect(() => { intervalRef.current = setInterval(() => { setProgress(prev => { if (prev >= 100) { if (intervalRef.current) clearInterval(intervalRef.current); return 100; } const increment = prev < 70 ? 0.5 : prev < 90 ? 0.2 : 0.1; return Math.min(prev + increment, 100); }); }, 200); return () => { if (intervalRef.current) clearInterval(intervalRef.current); }; }, []); useEffect(() => { if (!isComplete) return; if (intervalRef.current) clearInterval(intervalRef.current); setProgress(100); const timer = setTimeout(() => { onComplete?.(); }, 400); return () => clearTimeout(timer); }, [isComplete]); const getStepMessage = (p: number) => { if (p < 30) return t('analysis.loadingStep1'); if (p < 50) return t('analysis.loadingStep2'); if (p < 80) return t('analysis.loadingStep3'); return t('analysis.loadingStep4'); }; return (
{/* Logo */}
ADO2
{/* Loading Spinner and Text */}

{t('analysis.loadingTitle')}

Loading
{Math.floor(progress)}%

{getStepMessage(progress)}

); }; export default LoadingSection;