@@ -2154,18 +2154,10 @@ const Dispatch = ({
|
|||||||
// is already gated to active-order riders) so the tiles can't disagree with
|
// is already gated to active-order riders) so the tiles can't disagree with
|
||||||
// the list/map below.
|
// the list/map below.
|
||||||
if (isAllActiveView) {
|
if (isAllActiveView) {
|
||||||
// One order per rider, via getActiveOrder — the same "rider's single
|
const activeOrders = allOrders.filter(isActiveDelivery);
|
||||||
// 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 {
|
return {
|
||||||
orders: activeOrders.length,
|
orders: activeOrders.length,
|
||||||
riders: activeViewRiders.length,
|
riders: visibleRiders.length,
|
||||||
km: activeOrders.reduce((s, o) => s + parseFloat(o.actualkms || o.kms || 0), 0),
|
km: activeOrders.reduce((s, o) => s + parseFloat(o.actualkms || o.kms || 0), 0),
|
||||||
profit: activeOrders.reduce((s, o) => s + parseFloat(o.profit || 0), 0),
|
profit: activeOrders.reduce((s, o) => s + parseFloat(o.profit || 0), 0),
|
||||||
label: 'Active Fleet'
|
label: 'Active Fleet'
|
||||||
@@ -2178,7 +2170,7 @@ const Dispatch = ({
|
|||||||
profit: stats.totalProfit,
|
profit: stats.totalProfit,
|
||||||
label: 'Total Fleet'
|
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
|
// 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
|
// batched per-delivery GPS log fetch for Compare mode. Deduped; ignores rows
|
||||||
|
|||||||
Reference in New Issue
Block a user