diff --git a/src/pages/nearle/dispatch/Dispatch.js b/src/pages/nearle/dispatch/Dispatch.js index 84c7a2e..315c8b2 100644 --- a/src/pages/nearle/dispatch/Dispatch.js +++ b/src/pages/nearle/dispatch/Dispatch.js @@ -2154,18 +2154,10 @@ const Dispatch = ({ // is already gated to active-order riders) so the tiles can't disagree with // the list/map below. if (isAllActiveView) { - // 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); + const activeOrders = allOrders.filter(isActiveDelivery); return { orders: activeOrders.length, - riders: activeViewRiders.length, + riders: visibleRiders.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' @@ -2178,7 +2170,7 @@ const Dispatch = ({ profit: stats.totalProfit, label: 'Total Fleet' }; - }, [focusedRider, focusedKitchen, isAllActiveView, activeViewRiders, stats]); + }, [focusedRider, focusedKitchen, isAllActiveView, allViewOrders, visibleRiders, 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