Seth0330 commited on
Commit
582c857
·
verified ·
1 Parent(s): 89a11b6

Update frontend/src/pages/Dashboard.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/pages/Dashboard.jsx +216 -6
frontend/src/pages/Dashboard.jsx CHANGED
@@ -1,12 +1,222 @@
1
- import React from "react";
 
 
 
 
 
 
 
 
 
 
2
 
3
  export default function Dashboard() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  return (
5
- <div className="min-h-screen bg-[#FAFAFA] p-8">
6
- <h1 className="text-xl font-bold text-slate-900 mb-2">Document Extraction</h1>
7
- <p className="text-sm text-slate-500">
8
- This is a placeholder. Next step, we’ll plug in your full Base44 Dashboard UI here.
9
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  </div>
11
  );
12
  }
 
1
+ // frontend/src/pages/Dashboard.jsx
2
+
3
+ import React, { useState } from "react";
4
+ import { motion } from "framer-motion";
5
+ import { Sparkles, Zap, FileText, TrendingUp, Clock } from "lucide-react";
6
+ import { Button } from "@/components/ui/button";
7
+ import UploadZone from "@/components/ocr/UploadZone";
8
+ import DocumentPreview from "@/components/ocr/DocumentPreview";
9
+ import ExtractionOutput from "@/components/ocr/ExtractionOutput";
10
+ import ExportButtons from "@/components/ExportButtons";
11
+ import ProcessingStatus from "@/components/ocr/ProcessingStatus";
12
 
13
  export default function Dashboard() {
14
+ const [selectedFile, setSelectedFile] = useState(null);
15
+ const [isProcessing, setIsProcessing] = useState(false);
16
+ const [isComplete, setIsComplete] = useState(false);
17
+
18
+ const handleFileSelect = (file) => {
19
+ setSelectedFile(file);
20
+ setIsComplete(false);
21
+ };
22
+
23
+ const handleClear = () => {
24
+ setSelectedFile(null);
25
+ setIsProcessing(false);
26
+ setIsComplete(false);
27
+ };
28
+
29
+ const handleExtract = () => {
30
+ setIsProcessing(true);
31
+ // For now we simulate processing. Later we'll call FastAPI.
32
+ setTimeout(() => {
33
+ setIsProcessing(false);
34
+ setIsComplete(true);
35
+ }, 3000);
36
+ };
37
+
38
  return (
39
+ <div className="min-h-screen bg-[#FAFAFA]">
40
+ {/* Header */}
41
+ <header className="bg-white border-b border-slate-200/80 sticky top-0 z-40">
42
+ <div className="px-8 py-4 flex items-center justify-between">
43
+ <div>
44
+ <h1 className="text-xl font-bold text-slate-900 tracking-tight">
45
+ Document Extraction
46
+ </h1>
47
+ <p className="text-sm text-slate-500 mt-0.5">
48
+ Upload any document and extract structured data with AI
49
+ </p>
50
+ </div>
51
+ <div className="flex items-center gap-3">
52
+ {/* Stats Pills */}
53
+ <div className="hidden lg:flex items-center gap-2">
54
+ <div className="flex items-center gap-2 px-3 py-1.5 bg-slate-100 rounded-lg">
55
+ <FileText className="h-4 w-4 text-slate-500" />
56
+ <span className="text-sm font-medium text-slate-700">
57
+ 247 Extracted
58
+ </span>
59
+ </div>
60
+ <div className="flex items-center gap-2 px-3 py-1.5 bg-emerald-50 rounded-lg">
61
+ <TrendingUp className="h-4 w-4 text-emerald-600" />
62
+ <span className="text-sm font-medium text-emerald-700">
63
+ 98.5% Accuracy
64
+ </span>
65
+ </div>
66
+ </div>
67
+
68
+ <ExportButtons isComplete={isComplete} />
69
+ </div>
70
+ </div>
71
+ </header>
72
+
73
+ {/* Main Content */}
74
+ <div className="p-8">
75
+ {/* Upload Section */}
76
+ <motion.div
77
+ initial={{ opacity: 0, y: 20 }}
78
+ animate={{ opacity: 1, y: 0 }}
79
+ className="max-w-3xl mx-auto mb-8"
80
+ >
81
+ <UploadZone
82
+ onFileSelect={handleFileSelect}
83
+ selectedFile={selectedFile}
84
+ onClear={handleClear}
85
+ />
86
+
87
+ {/* Extract Button */}
88
+ {selectedFile && !isProcessing && !isComplete && (
89
+ <motion.div
90
+ initial={{ opacity: 0, y: 10 }}
91
+ animate={{ opacity: 1, y: 0 }}
92
+ className="mt-6 flex justify-center"
93
+ >
94
+ <Button
95
+ onClick={handleExtract}
96
+ size="lg"
97
+ className="h-14 px-8 rounded-2xl font-semibold text-base bg-gradient-to-r from-indigo-600 to-violet-600 hover:from-indigo-700 hover:to-violet-700 shadow-xl shadow-indigo-500/25 hover:shadow-2xl hover:shadow-indigo-500/30 transition-all duration-300 hover:-translate-y-0.5"
98
+ >
99
+ <Sparkles className="h-5 w-5 mr-2" />
100
+ Start AI Extraction
101
+ <Zap className="h-4 w-4 ml-2 opacity-70" />
102
+ </Button>
103
+ </motion.div>
104
+ )}
105
+ </motion.div>
106
+
107
+ {/* Processing Status */}
108
+ {(isProcessing || isComplete) && (
109
+ <div className="max-w-4xl mx-auto mb-8">
110
+ <ProcessingStatus
111
+ isProcessing={isProcessing}
112
+ isComplete={isComplete}
113
+ />
114
+ </div>
115
+ )}
116
+
117
+ {/* Split View */}
118
+ {selectedFile && (
119
+ <motion.div
120
+ initial={{ opacity: 0, y: 20 }}
121
+ animate={{ opacity: 1, y: 0 }}
122
+ transition={{ delay: 0.2 }}
123
+ className="grid grid-cols-1 lg:grid-cols-2 gap-6"
124
+ style={{ height: "calc(100vh - 420px)", minHeight: "500px" }}
125
+ >
126
+ <DocumentPreview file={selectedFile} isProcessing={isProcessing} />
127
+ <ExtractionOutput
128
+ hasFile={!!selectedFile}
129
+ isProcessing={isProcessing}
130
+ isComplete={isComplete}
131
+ />
132
+ </motion.div>
133
+ )}
134
+
135
+ {/* Empty State Features */}
136
+ {!selectedFile && (
137
+ <motion.div
138
+ initial={{ opacity: 0 }}
139
+ animate={{ opacity: 1 }}
140
+ transition={{ delay: 0.3 }}
141
+ className="max-w-5xl mx-auto mt-12"
142
+ >
143
+ <div className="text-center mb-10">
144
+ <h2 className="text-2xl font-bold text-slate-900 mb-2">
145
+ Powered by Advanced AI
146
+ </h2>
147
+ <p className="text-slate-500">
148
+ Extract structured data from any document in seconds
149
+ </p>
150
+ </div>
151
+
152
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
153
+ {[
154
+ {
155
+ icon: Zap,
156
+ title: "Lightning Fast",
157
+ description:
158
+ "Process documents in under 3 seconds with our optimized AI pipeline",
159
+ color: "amber",
160
+ },
161
+ {
162
+ icon: Sparkles,
163
+ title: "98.5% Accuracy",
164
+ description:
165
+ "Industry-leading extraction accuracy powered by GPT-4 Vision",
166
+ color: "indigo",
167
+ },
168
+ {
169
+ icon: Clock,
170
+ title: "Any Format",
171
+ description:
172
+ "Support for PDF, images, spreadsheets, and scanned documents",
173
+ color: "emerald",
174
+ },
175
+ ].map((feature, index) => (
176
+ <motion.div
177
+ key={feature.title}
178
+ initial={{ opacity: 0, y: 20 }}
179
+ animate={{ opacity: 1, y: 0 }}
180
+ transition={{ delay: 0.4 + index * 0.1 }}
181
+ className="group bg-white rounded-2xl border border-slate-200 p-6 hover:shadow-xl hover:shadow-slate-200/50 transition-all duration-300 hover:-translate-y-1"
182
+ >
183
+ <div
184
+ className={`h-12 w-12 rounded-xl bg-${feature.color}-50 flex items-center justify-center mb-4 group-hover:scale-110 transition-transform duration-300`}
185
+ >
186
+ <feature.icon
187
+ className={`h-6 w-6 text-${feature.color}-600`}
188
+ />
189
+ </div>
190
+ <h3 className="font-semibold text-slate-900 mb-2">
191
+ {feature.title}
192
+ </h3>
193
+ <p className="text-sm text-slate-500 leading-relaxed">
194
+ {feature.description}
195
+ </p>
196
+ </motion.div>
197
+ ))}
198
+ </div>
199
+
200
+ {/* Supported Formats */}
201
+ <div className="mt-12 text-center">
202
+ <p className="text-xs text-slate-400 uppercase tracking-wider mb-4 font-medium">
203
+ Supported Formats
204
+ </p>
205
+ <div className="flex items-center justify-center gap-6 flex-wrap">
206
+ {["PDF", "PNG", "JPG", "TIFF", "DOCX", "XLSX"].map((format) => (
207
+ <div
208
+ key={format}
209
+ className="flex items-center gap-2 text-slate-400"
210
+ >
211
+ <FileText className="h-4 w-4" />
212
+ <span className="text-sm font-medium">{format}</span>
213
+ </div>
214
+ ))}
215
+ </div>
216
+ </div>
217
+ </motion.div>
218
+ )}
219
+ </div>
220
  </div>
221
  );
222
  }