From a8e6ded810e19e95ca7439b03ce3740f273a2b5c Mon Sep 17 00:00:00 2001 From: David Date: Tue, 16 Dec 2025 13:41:32 +0100 Subject: [PATCH] fix dasboard --- apps/frontend/app/dashboard/page.tsx | 640 +++++++++++++++------------ 1 file changed, 354 insertions(+), 286 deletions(-) diff --git a/apps/frontend/app/dashboard/page.tsx b/apps/frontend/app/dashboard/page.tsx index 1969448..f1afe89 100644 --- a/apps/frontend/app/dashboard/page.tsx +++ b/apps/frontend/app/dashboard/page.tsx @@ -1,7 +1,6 @@ /** - * Dashboard Home Page - * - * Main dashboard with CSV Booking KPIs and carrier analytics + * Dashboard Home Page - Clean & Colorful with Charts + * Professional design with data visualization */ 'use client'; @@ -22,6 +21,21 @@ import { Plus, ArrowRight, } from 'lucide-react'; +import { + PieChart, + Pie, + Cell, + BarChart, + Bar, + XAxis, + YAxis, + CartesianGrid, + Tooltip, + ResponsiveContainer, + LineChart, + Line, + Legend, +} from 'recharts'; export default function DashboardPage() { // Fetch CSV booking KPIs @@ -36,138 +50,240 @@ export default function DashboardPage() { queryFn: () => dashboardApi.getTopCarriers(), }); + // Prepare data for charts + const statusDistribution = csvKpis + ? [ + { name: 'Acceptés', value: csvKpis.totalAccepted, color: '#10b981' }, + { name: 'Refusés', value: csvKpis.totalRejected, color: '#ef4444' }, + { name: 'En Attente', value: csvKpis.totalPending, color: '#f59e0b' }, + ] + : []; + + const carrierWeightData = topCarriers + ? topCarriers.slice(0, 5).map(c => ({ + name: c.carrierName.length > 15 ? c.carrierName.substring(0, 15) + '...' : c.carrierName, + poids: Math.round(c.totalWeightKG), + })) + : []; + return ( -
- {/* Header Section */} -
-
-

Dashboard

-

- Suivez vos bookings et vos performances -

+
+
+ {/* Header - Compact */} +
+
+

Tableau de Bord

+

+ Vue d'ensemble de vos bookings et performances +

+
+ + + +
- {/* CTA Button */} - - - -
- - {/* KPI Cards Grid */} -
- {/* Bookings Acceptés */} - - - Bookings Acceptés - - - - {csvKpisLoading ? ( -
- ) : ( - <> -
{csvKpis?.totalAccepted || 0}
-

- +{csvKpis?.acceptedThisMonth || 0} ce mois -

- - )} - - - - {/* Bookings Refusés */} - - - Bookings Refusés - - - - {csvKpisLoading ? ( -
- ) : ( - <> -
{csvKpis?.totalRejected || 0}
-

- +{csvKpis?.rejectedThisMonth || 0} ce mois -

- - )} - - - - {/* Bookings En Attente */} - - - En Attente - - - - {csvKpisLoading ? ( -
- ) : ( - <> -
{csvKpis?.totalPending || 0}
-

- {csvKpis?.acceptanceRate.toFixed(1)}% taux d'acceptation -

- - )} - - - - {/* Poids Total Accepté */} - - - Poids Total Accepté - - - - {csvKpisLoading ? ( -
- ) : ( - <> -
- {(csvKpis?.totalWeightAcceptedKG || 0).toLocaleString()} + {/* KPI Cards - Compact with Color */} +
+ {/* Bookings Acceptés */} + + +
+
+
-

- KG ({(csvKpis?.totalVolumeAcceptedCBM || 0).toFixed(2)} CBM) -

- - )} - - -
- - {/* Stats Overview Card */} - - - Vue d'ensemble - Statistiques globales de vos bookings - - -
-
-
- +

Acceptés

+ {csvKpisLoading ? ( +
+ ) : ( + <> +

+ {csvKpis?.totalAccepted || 0} +

+

+ +{csvKpis?.acceptedThisMonth || 0} ce mois +

+ + )}
-
-

Taux d'acceptation

-

+ + + + {/* Bookings Refusés */} + + +

+
+ +
+

Refusés

+ {csvKpisLoading ? ( +
+ ) : ( + <> +

+ {csvKpis?.totalRejected || 0} +

+

+ +{csvKpis?.rejectedThisMonth || 0} ce mois +

+ + )} +
+ + + + {/* Bookings En Attente */} + + +
+
+ +
+

En Attente

+ {csvKpisLoading ? ( +
+ ) : ( + <> +

+ {csvKpis?.totalPending || 0} +

+

+ {csvKpis?.acceptanceRate.toFixed(1)}% acceptés +

+ + )} +
+ + + + {/* Poids Total */} + + +
+
+ +
+

Poids Total

+ {csvKpisLoading ? ( +
+ ) : ( + <> +

+ {(csvKpis?.totalWeightAcceptedKG || 0).toLocaleString()} +

+

+ KG • {(csvKpis?.totalVolumeAcceptedCBM || 0).toFixed(1)} CBM +

+ + )} +
+ + +
+ + {/* Charts Section */} +
+ {/* Distribution des Statuts - Pie Chart */} + + + + Distribution des Bookings + + + Répartition par statut + + + + {csvKpisLoading ? ( +
+ ) : ( + + + + `${name} ${(percent * 100).toFixed(0)}%` + } + outerRadius={70} + fill="#8884d8" + dataKey="value" + > + {statusDistribution.map((entry, index) => ( + + ))} + + + + + )} + + + + {/* Poids par Transporteur - Bar Chart */} + + + + Poids par Transporteur + + + Top 5 carriers par poids (KG) + + + + {carriersLoading ? ( +
+ ) : ( + + + + + + + + + + )} + + +
+ + {/* Performance Overview - Compact */} +
+ + +
+
+ +
+

Taux d'Acceptation

+

{csvKpisLoading ? '--' : `${csvKpis?.acceptanceRate.toFixed(1)}%`}

-
+
+
-
-
- -
-
-

Total bookings

-

+ + +

+
+ +
+

Total Bookings

+

{csvKpisLoading ? '--' : (csvKpis?.totalAccepted || 0) + @@ -175,178 +291,130 @@ export default function DashboardPage() { (csvKpis?.totalPending || 0)}

-
+ + -
-
- -
-
-

Volume total accepté

-

+ + +

+
+ +
+

Volume Total

+

{csvKpisLoading ? '--' : `${(csvKpis?.totalVolumeAcceptedCBM || 0).toFixed(1)}`} - CBM + CBM

-
-
- - + + +
- {/* Top Carriers Section */} - - -
-
- Meilleures Compagnies - Top 5 des transporteurs avec qui vous avez le plus booké -
- - - -
-
- - {carriersLoading ? ( -
- {Array.from({ length: 5 }).map((_, i) => ( -
- ))} -
- ) : topCarriers && topCarriers.length > 0 ? ( -
- {topCarriers.map((carrier, index) => ( -
+ +
+
+ + Top Transporteurs + + + Classement des meilleures compagnies + +
+ +
- ))} -
- ) : ( -
- -

Aucun booking pour l'instant

-

- Créez votre premier booking pour voir vos statistiques -

- -
- )} - - + + + {carriersLoading ? ( +
+ {Array.from({ length: 3 }).map((_, i) => ( +
+
+
+ ))} +
+ ) : topCarriers && topCarriers.length > 0 ? ( +
+ {topCarriers.slice(0, 5).map((carrier, index) => ( +
+
+
+
+ {index + 1} +
+
+

+ {carrier.carrierName} +

+
+ {carrier.totalBookings} bookings + + {carrier.totalWeightKG.toLocaleString()} KG +
+
+
- {/* Quick Actions */} -
- - - -
- - - +
+
+
+ + {carrier.acceptedBookings} ✓ + + {carrier.rejectedBookings > 0 && ( + + {carrier.rejectedBookings} ✗ + + )} +
+

+ {carrier.acceptanceRate.toFixed(0)}% • ${carrier.avgPriceUSD.toFixed(0)} +

+
+
+
+
+ ))}
-
-

Rechercher des tarifs

-

Trouver les meilleurs prix

+ ) : ( +
+
+ +
+

+ Aucun booking +

+

+ Créez votre premier booking pour voir vos statistiques +

+ + +
- - - - - - - -
- -
-
-

Mes Bookings

-

Voir tous mes envois

-
-
-
- - - - - -
- - - - -
-
-

Paramètres

-

Configuration du compte

-
-
-
- + )} + +
);