/** * UploadProgress — file upload status indicators. * * Shows a list of files being uploaded with progress bars, * completion checkmarks, and error states. */ import { AlertCircle, CheckCircle2, FileText, Loader2, RefreshCw, X } from "lucide-react"; import { cn } from "../lib/utils"; export interface UploadFile { id: string; name: string; size: number; status: "pending" | "uploading" | "complete" | "error"; progress?: number; // 0-100 error?: string; } export interface UploadProgressProps { files: UploadFile[]; onRemove?: (id: string) => void; onRetry?: (id: string) => void; className?: string; } function formatSize(bytes: number): string { if (bytes < 1024) return `${bytes}B`; if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)}KB`; return `${(bytes / (1024 * 1024)).toFixed(1)}MB`; } export function UploadProgress({ files, onRemove, onRetry, className }: UploadProgressProps) { if (files.length === 0) return null; return (
{files.map((file) => (
{/* Icon */} {file.status === "complete" && ( )} {file.status === "error" && ( )} {file.status === "uploading" && ( )} {file.status === "pending" && ( )} {/* Name + size */}
{file.name} {formatSize(file.size)}
{/* Progress bar */} {file.status === "uploading" && file.progress !== undefined && (
)} {/* Error message */} {file.status === "error" && file.error && (

{file.error}

)}
{/* Actions */}
{file.status === "error" && onRetry && ( )} {onRemove && ( )}
))}
); }