Yassine Mhirsi commited on
Commit ·
5f83845
1
Parent(s): b50a96a
Enhance AnalysisPage and Loading component
Browse files- Updated AnalysisPage to improve the display of user analysis statistics, including a new message for when no data is available.
- Refactored loading states for better user experience during data analysis.
- Enhanced Loading component styles for dark mode compatibility.
src/app/components/common/Loading.tsx
CHANGED
|
@@ -18,11 +18,11 @@ const Loading: React.FC<LoadingProps> = ({ size = 'md', text }) => {
|
|
| 18 |
return (
|
| 19 |
<div className="flex flex-col items-center justify-center p-4">
|
| 20 |
<div
|
| 21 |
-
className={`${sizeClasses[size]} animate-spin rounded-full border-4 border-gray-200 border-t-blue-600`}
|
| 22 |
role="status"
|
| 23 |
aria-label="Loading"
|
| 24 |
/>
|
| 25 |
-
{text && <p className="mt-2 text-sm text-gray-600">{text}</p>}
|
| 26 |
</div>
|
| 27 |
);
|
| 28 |
};
|
|
|
|
| 18 |
return (
|
| 19 |
<div className="flex flex-col items-center justify-center p-4">
|
| 20 |
<div
|
| 21 |
+
className={`${sizeClasses[size]} animate-spin rounded-full border-4 border-gray-200 dark:border-zinc-700 border-t-blue-600 dark:border-t-blue-500`}
|
| 22 |
role="status"
|
| 23 |
aria-label="Loading"
|
| 24 |
/>
|
| 25 |
+
{text && <p className="mt-2 text-sm text-gray-600 dark:text-zinc-400">{text}</p>}
|
| 26 |
</div>
|
| 27 |
);
|
| 28 |
};
|
src/app/pages/AnalysisPage.tsx
CHANGED
|
@@ -142,26 +142,31 @@ const AnalysisPage: React.FC = () => {
|
|
| 142 |
<div className="min-h-screen bg-slate-50 dark:bg-black px-4 pt-20 pb-10 transition-colors duration-200">
|
| 143 |
<div className="mx-auto max-w-7xl space-y-6">
|
| 144 |
{/* Statistics Section */}
|
| 145 |
-
|
| 146 |
-
<div className="
|
| 147 |
-
<
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
<p className="text-sm text-slate-500 dark:text-zinc-400">
|
| 152 |
-
|
| 153 |
</p>
|
| 154 |
</div>
|
| 155 |
-
|
| 156 |
-
{isLoadingStats ? (
|
| 157 |
-
<div className="flex items-center justify-center py-12">
|
| 158 |
-
<Loading />
|
| 159 |
-
</div>
|
| 160 |
-
) : statsError ? (
|
| 161 |
-
<div className="px-6 py-4">
|
| 162 |
-
<p className="text-sm text-red-600 dark:text-red-400">{statsError}</p>
|
| 163 |
-
</div>
|
| 164 |
-
) : (
|
| 165 |
<div className="p-6 space-y-8">
|
| 166 |
{/* Summary Statistics */}
|
| 167 |
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
@@ -241,7 +246,6 @@ const AnalysisPage: React.FC = () => {
|
|
| 241 |
</div>
|
| 242 |
)}
|
| 243 |
</div>
|
| 244 |
-
)}
|
| 245 |
|
| 246 |
{/* CSV Upload and Analysis Section */}
|
| 247 |
<div className="rounded-lg border border-slate-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 shadow-sm">
|
|
@@ -325,7 +329,13 @@ const AnalysisPage: React.FC = () => {
|
|
| 325 |
</div>
|
| 326 |
)}
|
| 327 |
|
| 328 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
<div className="overflow-hidden rounded-lg border border-slate-200 dark:border-zinc-700">
|
| 330 |
<div className="bg-green-50 dark:bg-green-900/20 px-4 py-2 border-b border-slate-200 dark:border-zinc-700">
|
| 331 |
<h2 className="text-sm font-semibold text-green-800 dark:text-green-400">
|
|
|
|
| 142 |
<div className="min-h-screen bg-slate-50 dark:bg-black px-4 pt-20 pb-10 transition-colors duration-200">
|
| 143 |
<div className="mx-auto max-w-7xl space-y-6">
|
| 144 |
{/* Statistics Section */}
|
| 145 |
+
<div className="rounded-lg border border-slate-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 shadow-sm">
|
| 146 |
+
<div className="border-b border-slate-200 dark:border-zinc-700 px-6 py-4">
|
| 147 |
+
<h2 className="text-lg font-semibold text-slate-800 dark:text-white">
|
| 148 |
+
Your Analysis Statistics
|
| 149 |
+
</h2>
|
| 150 |
+
<p className="text-sm text-slate-500 dark:text-zinc-400">
|
| 151 |
+
Overview of all your analyzed arguments
|
| 152 |
+
</p>
|
| 153 |
+
</div>
|
| 154 |
+
|
| 155 |
+
{isLoadingStats ? (
|
| 156 |
+
<div className="flex items-center justify-center py-12">
|
| 157 |
+
<Loading />
|
| 158 |
+
</div>
|
| 159 |
+
) : statsError ? (
|
| 160 |
+
<div className="px-6 py-4">
|
| 161 |
+
<p className="text-sm text-red-600 dark:text-red-400">{statsError}</p>
|
| 162 |
+
</div>
|
| 163 |
+
) : userAnalysisData.length === 0 ? (
|
| 164 |
+
<div className="px-6 py-4">
|
| 165 |
<p className="text-sm text-slate-500 dark:text-zinc-400">
|
| 166 |
+
No analysis data available yet. Upload and analyze a CSV file to see statistics.
|
| 167 |
</p>
|
| 168 |
</div>
|
| 169 |
+
) : (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
<div className="p-6 space-y-8">
|
| 171 |
{/* Summary Statistics */}
|
| 172 |
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
|
|
| 246 |
</div>
|
| 247 |
)}
|
| 248 |
</div>
|
|
|
|
| 249 |
|
| 250 |
{/* CSV Upload and Analysis Section */}
|
| 251 |
<div className="rounded-lg border border-slate-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 shadow-sm">
|
|
|
|
| 329 |
</div>
|
| 330 |
)}
|
| 331 |
|
| 332 |
+
{isAnalyzing && (
|
| 333 |
+
<div className="flex items-center justify-center py-12">
|
| 334 |
+
<Loading text="Analyzing arguments..." />
|
| 335 |
+
</div>
|
| 336 |
+
)}
|
| 337 |
+
|
| 338 |
+
{!isAnalyzing && analysisResults.length > 0 && (
|
| 339 |
<div className="overflow-hidden rounded-lg border border-slate-200 dark:border-zinc-700">
|
| 340 |
<div className="bg-green-50 dark:bg-green-900/20 px-4 py-2 border-b border-slate-200 dark:border-zinc-700">
|
| 341 |
<h2 className="text-sm font-semibold text-green-800 dark:text-green-400">
|