/** * Dashboard Home Page - Clean & Colorful with Charts * Professional design with data visualization */ 'use client'; import { useQuery } from '@tanstack/react-query'; import { dashboardApi } from '@/lib/api'; import Link from 'next/link'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Package, PackageCheck, PackageX, Clock, Weight, TrendingUp, 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 const { data: csvKpis, isLoading: csvKpisLoading } = useQuery({ queryKey: ['dashboard', 'csv-booking-kpis'], queryFn: () => dashboardApi.getCsvBookingKPIs(), }); // Fetch top carriers const { data: topCarriers, isLoading: carriersLoading } = useQuery({ queryKey: ['dashboard', 'top-carriers'], 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 (
Vue d'ensemble de vos bookings et performances
Acceptés
{csvKpisLoading ? ( ) : ( <>{csvKpis?.totalAccepted || 0}
+{csvKpis?.acceptedThisMonth || 0} ce mois
> )}Refusés
{csvKpisLoading ? ( ) : ( <>{csvKpis?.totalRejected || 0}
+{csvKpis?.rejectedThisMonth || 0} ce mois
> )}En Attente
{csvKpisLoading ? ( ) : ( <>{csvKpis?.totalPending || 0}
{csvKpis?.acceptanceRate.toFixed(1)}% acceptés
> )}Poids Total
{csvKpisLoading ? ( ) : ( <>{(csvKpis?.totalWeightAcceptedKG || 0).toLocaleString()}
KG • {(csvKpis?.totalVolumeAcceptedCBM || 0).toFixed(1)} CBM
> )}Taux d'Acceptation
{csvKpisLoading ? '--' : `${csvKpis?.acceptanceRate.toFixed(1)}%`}
Total Bookings
{csvKpisLoading ? '--' : (csvKpis?.totalAccepted || 0) + (csvKpis?.totalRejected || 0) + (csvKpis?.totalPending || 0)}
Volume Total
{csvKpisLoading ? '--' : `${(csvKpis?.totalVolumeAcceptedCBM || 0).toFixed(1)}`} CBM
{carrier.acceptanceRate.toFixed(0)}% • ${carrier.avgPriceUSD.toFixed(0)}
Créez votre premier booking pour voir vos statistiques