import { useState, useEffect } from 'react' const analysisSteps = [ { text: 'Reading image metadata...', icon: '📷' }, { text: 'Analyzing depth of field...', icon: '🔍' }, { text: 'Detecting light sources...', icon: '💡' }, { text: 'Extracting color palette...', icon: '🎨' }, { text: 'Analyzing tone curve...', icon: '📊' }, { text: 'Generating recommendations...', icon: '✨' }, ] function LoadingAnalysis({ imagePreview }) { const [currentStep, setCurrentStep] = useState(0) const [elapsedTime, setElapsedTime] = useState(0) useEffect(() => { // Progress through steps without looping const stepInterval = setInterval(() => { setCurrentStep((prev) => { // Stop at the last step instead of looping if (prev >= analysisSteps.length - 1) { return prev } return prev + 1 }) }, 800) // Track elapsed time for the progress bar const timeInterval = setInterval(() => { setElapsedTime((prev) => prev + 100) }, 100) return () => { clearInterval(stepInterval) clearInterval(timeInterval) } }, []) // Estimate progress (assume ~5 seconds typical analysis time) const estimatedDuration = 5000 const progress = Math.min((elapsedTime / estimatedDuration) * 100, 95) return (
Uploaded
Processing image... {Math.round(progress)}%
{/* Progress bar */}

Analyzing Your Shot

{analysisSteps.map((step, index) => { const isActive = index === currentStep const isComplete = index < currentStep const isLast = index === analysisSteps.length - 1 const isWaiting = isActive && isLast && progress > 80 return (
{step.icon} {isWaiting ? 'Finishing up...' : step.text} {isActive && (
)} {isComplete && ( )}
) })}
) } export default LoadingAnalysis