updates on the dispatch page

This commit is contained in:
2026-07-01 13:23:23 +05:30
parent 360b13a467
commit e21a1e66b5

View File

@@ -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