Spaces:
Running
Running
Create frontend/src/components/ocr/ProcessingStatus.jsx
Browse files
frontend/src/components/ocr/ProcessingStatus.jsx
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from "react";
|
| 2 |
+
import { motion } from "framer-motion";
|
| 3 |
+
import {
|
| 4 |
+
FileSearch,
|
| 5 |
+
Cpu,
|
| 6 |
+
TableProperties,
|
| 7 |
+
CheckCircle2,
|
| 8 |
+
Loader2,
|
| 9 |
+
} from "lucide-react";
|
| 10 |
+
import { cn } from "@/lib/utils";
|
| 11 |
+
|
| 12 |
+
const steps = [
|
| 13 |
+
{ id: "upload", label: "Document Received", icon: FileSearch },
|
| 14 |
+
{ id: "analyze", label: "AI Analysis", icon: Cpu },
|
| 15 |
+
{ id: "extract", label: "Data Extraction", icon: TableProperties },
|
| 16 |
+
{ id: "complete", label: "Complete", icon: CheckCircle2 },
|
| 17 |
+
];
|
| 18 |
+
|
| 19 |
+
export default function ProcessingStatus({ isProcessing, isComplete }) {
|
| 20 |
+
const getCurrentStep = () => {
|
| 21 |
+
if (isComplete) return 4;
|
| 22 |
+
if (isProcessing) return 2;
|
| 23 |
+
return 0;
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
const currentStep = getCurrentStep();
|
| 27 |
+
|
| 28 |
+
if (!isProcessing && !isComplete) return null;
|
| 29 |
+
|
| 30 |
+
return (
|
| 31 |
+
<motion.div
|
| 32 |
+
initial={{ opacity: 0, y: -10 }}
|
| 33 |
+
animate={{ opacity: 1, y: 0 }}
|
| 34 |
+
className="bg-white rounded-2xl border border-slate-200 p-6"
|
| 35 |
+
>
|
| 36 |
+
<div className="flex items-center justify-between">
|
| 37 |
+
{steps.map((step, index) => {
|
| 38 |
+
const isActive = index + 1 === currentStep;
|
| 39 |
+
const isCompleted = index + 1 < currentStep;
|
| 40 |
+
const Icon = step.icon;
|
| 41 |
+
|
| 42 |
+
return (
|
| 43 |
+
<React.Fragment key={step.id}>
|
| 44 |
+
<div className="flex flex-col items-center">
|
| 45 |
+
<motion.div
|
| 46 |
+
initial={false}
|
| 47 |
+
animate={{
|
| 48 |
+
scale: isActive ? 1.1 : 1,
|
| 49 |
+
backgroundColor: isCompleted
|
| 50 |
+
? "rgb(16 185 129)"
|
| 51 |
+
: isActive
|
| 52 |
+
? "rgb(99 102 241)"
|
| 53 |
+
: "rgb(241 245 249)",
|
| 54 |
+
}}
|
| 55 |
+
className={cn(
|
| 56 |
+
"h-12 w-12 rounded-xl flex items-center justify-center mb-2 transition-colors",
|
| 57 |
+
(isCompleted || isActive) && "shadow-lg"
|
| 58 |
+
)}
|
| 59 |
+
style={{
|
| 60 |
+
boxShadow: isActive
|
| 61 |
+
? "0 8px 16px -4px rgba(99, 102, 241, 0.3)"
|
| 62 |
+
: isCompleted
|
| 63 |
+
? "0 8px 16px -4px rgba(16, 185, 129, 0.3)"
|
| 64 |
+
: "none",
|
| 65 |
+
}}
|
| 66 |
+
>
|
| 67 |
+
{isActive ? (
|
| 68 |
+
<motion.div
|
| 69 |
+
animate={{ rotate: 360 }}
|
| 70 |
+
transition={{
|
| 71 |
+
duration: 1.5,
|
| 72 |
+
repeat: Infinity,
|
| 73 |
+
ease: "linear",
|
| 74 |
+
}}
|
| 75 |
+
>
|
| 76 |
+
<Loader2 className="h-5 w-5 text-white" />
|
| 77 |
+
</motion.div>
|
| 78 |
+
) : (
|
| 79 |
+
<Icon
|
| 80 |
+
className={cn(
|
| 81 |
+
"h-5 w-5",
|
| 82 |
+
isCompleted ? "text-white" : "text-slate-400"
|
| 83 |
+
)}
|
| 84 |
+
/>
|
| 85 |
+
)}
|
| 86 |
+
</motion.div>
|
| 87 |
+
<span
|
| 88 |
+
className={cn(
|
| 89 |
+
"text-xs font-medium text-center",
|
| 90 |
+
isActive
|
| 91 |
+
? "text-indigo-600"
|
| 92 |
+
: isCompleted
|
| 93 |
+
? "text-emerald-600"
|
| 94 |
+
: "text-slate-400"
|
| 95 |
+
)}
|
| 96 |
+
>
|
| 97 |
+
{step.label}
|
| 98 |
+
</span>
|
| 99 |
+
</div>
|
| 100 |
+
|
| 101 |
+
{index < steps.length - 1 && (
|
| 102 |
+
<div className="flex-1 h-0.5 mx-4 mb-6 relative overflow-hidden rounded-full bg-slate-100">
|
| 103 |
+
<motion.div
|
| 104 |
+
initial={{ width: 0 }}
|
| 105 |
+
animate={{
|
| 106 |
+
width: isCompleted ? "100%" : isActive ? "50%" : "0%",
|
| 107 |
+
}}
|
| 108 |
+
transition={{ duration: 0.5 }}
|
| 109 |
+
className={cn(
|
| 110 |
+
"absolute inset-y-0 left-0",
|
| 111 |
+
isCompleted ? "bg-emerald-500" : "bg-indigo-500"
|
| 112 |
+
)}
|
| 113 |
+
/>
|
| 114 |
+
</div>
|
| 115 |
+
)}
|
| 116 |
+
</React.Fragment>
|
| 117 |
+
);
|
| 118 |
+
})}
|
| 119 |
+
</div>
|
| 120 |
+
</motion.div>
|
| 121 |
+
);
|
| 122 |
+
}
|