import React from 'react' import { AnimatePresence, motion, useReducedMotion } from 'framer-motion' export default function UploadProgress({ title = 'Upload Artwork', description = 'Preload → Details → Publish', progress = 24, status = 'Idle', state, processingStatus, processingLabel = '', isCancelling = false, error = '', onRetry, onReset, }) { const prefersReducedMotion = useReducedMotion() const getRecoveryHint = () => { const text = String(error || '').toLowerCase() if (!text) return '' if (text.includes('network') || text.includes('timeout') || text.includes('failed to fetch')) { return 'Your connection may be unstable. Retry now or wait a moment and try again.' } if (text.includes('busy') || text.includes('unavailable') || text.includes('503') || text.includes('server')) { return 'The server looks busy right now. Waiting 20–30 seconds before retrying can help.' } if (text.includes('validation') || text.includes('invalid') || text.includes('too large') || text.includes('format')) { return 'Please review the file requirements, then update your selection and try again.' } return 'You can retry now, or reset this upload and start again with the same files.' } const recoveryHint = getRecoveryHint() const resolvedStatus = (() => { if (isCancelling) return 'Processing' if (state === 'error') return 'Error' if (processingStatus === 'ready') return 'Ready' if (state === 'uploading') return 'Uploading' if (state === 'processing' || state === 'finishing' || state === 'publishing') return 'Processing' if (status) return status return 'Idle' })() const statusTheme = { Idle: 'border-slate-400/35 bg-slate-400/15 text-slate-200', Uploading: 'border-sky-400/35 bg-sky-400/15 text-sky-100', Processing: 'border-amber-400/35 bg-amber-400/15 text-amber-100', Ready: 'border-emerald-400/35 bg-emerald-400/15 text-emerald-100', Error: 'border-red-400/35 bg-red-400/15 text-red-100', } const statusColors = { Idle: { borderColor: 'rgba(148,163,184,0.35)', backgroundColor: 'rgba(148,163,184,0.15)', color: 'rgb(226,232,240)' }, Uploading: { borderColor: 'rgba(56,189,248,0.35)', backgroundColor: 'rgba(56,189,248,0.15)', color: 'rgb(224,242,254)' }, Processing: { borderColor: 'rgba(251,191,36,0.35)', backgroundColor: 'rgba(251,191,36,0.15)', color: 'rgb(254,243,199)' }, Ready: { borderColor: 'rgba(52,211,153,0.35)', backgroundColor: 'rgba(52,211,153,0.15)', color: 'rgb(209,250,229)' }, Error: { borderColor: 'rgba(248,113,113,0.35)', backgroundColor: 'rgba(248,113,113,0.15)', color: 'rgb(254,226,226)' }, } const quickTransition = prefersReducedMotion ? { duration: 0 } : { duration: 0.2, ease: 'easeOut' } const stepLabels = ['Preload', 'Details', 'Publish'] const stepIndex = progress >= 100 ? 2 : progress >= 34 ? 1 : 0 return (
{/* Intended props: step, steps, phase, badge, progress, statusMessage */}

{title}

{description}

{resolvedStatus}
{stepLabels.map((label, idx) => { const active = idx <= stepIndex return (
{label} {idx < stepLabels.length - 1 && }
) })}

{Math.round(progress)}%

{(state === 'processing' || state === 'finishing' || state === 'publishing' || isCancelling) && ( {processingLabel || 'Analyzing content'} — you can continue editing details while processing finishes. )} {error && (

Something went wrong while uploading.

You can retry safely. {error}

{recoveryHint &&

{recoveryHint}

}
)}
) }