From e21a1e66b5099fc0bf3b4627df5ddd90136615d8 Mon Sep 17 00:00:00 2001 From: dharaneesh-r Date: Wed, 1 Jul 2026 13:23:23 +0530 Subject: [PATCH] updates on the dispatch page --- src/pages/nearle/dispatch/Dispatch.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/nearle/dispatch/Dispatch.js b/src/pages/nearle/dispatch/Dispatch.js index 315c8b2..84c7a2e 100644 --- a/src/pages/nearle/dispatch/Dispatch.js +++ b/src/pages/nearle/dispatch/Dispatch.js @@ -2154,10 +2154,18 @@ const Dispatch = ({ // is already gated to active-order riders) so the tiles can't disagree with // the list/map below. if (isAllActiveView) { - const activeOrders = allOrders.filter(isActiveDelivery); + // One order per rider, via getActiveOrder — the same "rider's single + // in-progress delivery" resolver used elsewhere on this page (see + // dispatchShared.js). A multi-drop batch can carry `orderstatus: + // 'active'` on more than one of a rider's stops at once (the current + // leg plus a queued one), so filtering allViewOrders by isActiveDelivery + // directly counted every such row and let Orders outnumber the distinct + // riders backing them (e.g. 5 orders / 3 riders). Resolving exactly one + // active order per activeViewRiders entry keeps the two tiles 1:1. + const activeOrders = activeViewRiders.map((r) => getActiveOrder(r.orders)).filter(Boolean); return { orders: activeOrders.length, - riders: visibleRiders.length, + riders: activeViewRiders.length, km: activeOrders.reduce((s, o) => s + parseFloat(o.actualkms || o.kms || 0), 0), profit: activeOrders.reduce((s, o) => s + parseFloat(o.profit || 0), 0), label: 'Active Fleet' @@ -2170,7 +2178,7 @@ const Dispatch = ({ profit: stats.totalProfit, label: 'Total Fleet' }; - }, [focusedRider, focusedKitchen, isAllActiveView, allViewOrders, visibleRiders, stats]); + }, [focusedRider, focusedKitchen, isAllActiveView, activeViewRiders, stats]); // List of deliveryids tied to the focused rider's orders — used to drive the // batched per-delivery GPS log fetch for Compare mode. Deduped; ignores rows