From dbca763d4be8727cd312a4381f11855255313c89 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Mon, 1 Sep 2025 20:19:27 +0000 Subject: [PATCH] Display all pending orders on the dashboard regardless of creation date Updates the dashboard to filter and display all orders with a 'pending' status, including sorting by creation date and highlighting overdue orders. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 98f01874-e00c-4bbe-9d71-b0b338001848 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/98f01874-e00c-4bbe-9d71-b0b338001848/XDIQsDu --- client/src/pages/Dashboard.tsx | 73 ++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/client/src/pages/Dashboard.tsx b/client/src/pages/Dashboard.tsx index 79726a9..6fb21ec 100644 --- a/client/src/pages/Dashboard.tsx +++ b/client/src/pages/Dashboard.tsx @@ -224,6 +224,15 @@ export default function Dashboard() { return (dateB ? dateB.getTime() : 0) - (dateA ? dateA.getTime() : 0); }) .slice(0, 4) : []; // Afficher les 4 dernières commandes + + // Toutes les commandes en attente (peu importe la date) + const pendingOrders = Array.isArray(allOrders) ? allOrders + .filter((order: any) => order.status === 'pending') + .sort((a: any, b: any) => { + const dateA = safeDate(a.createdAt); + const dateB = safeDate(b.createdAt); + return (dateB ? dateB.getTime() : 0) - (dateA ? dateA.getTime() : 0); + }) : []; const upcomingDeliveries = Array.isArray(allDeliveries) ? allDeliveries .filter((d: any) => { @@ -440,38 +449,52 @@ export default function Dashboard() { {/* Main Content Grid */}
- {/* Dernières Commandes */} + {/* Commandes en Attente */} - - Dernières Commandes + + Commandes en Attente + {pendingOrders.length > 0 && ( + + {pendingOrders.length} + + )} - - {recentOrders.length > 0 ? recentOrders.map((order: any) => ( -
-
-
-
-

{order.supplier?.name}

-

{order.group?.name}

+ + {pendingOrders.length > 0 ? pendingOrders.map((order: any) => { + // Calculer le nombre de jours en attente + const orderDate = safeDate(order.createdAt); + const daysPending = orderDate ? Math.floor((new Date().getTime() - orderDate.getTime()) / (1000 * 60 * 60 * 24)) : 0; + const isOverdue = daysPending > 10; + + return ( +
+
+
+
+

{order.supplier?.name}

+

{order.group?.name}

+
+
+
+ + {daysPending} jour{daysPending > 1 ? 's' : ''} + +

+ {safeFormat(order.plannedDate, "d MMM")} +

-
- - {order.status === 'delivered' ? 'Livrée' : order.status === 'planned' ? 'Planifiée' : 'En attente'} - -

- {safeFormat(order.plannedDate, "d MMM")} -

-
-
- )) : ( -

Aucune commande récente

+ ); + }) : ( +

Aucune commande en attente

)}