updates on the dispatch page faster improvements fix
This commit is contained in:
@@ -2150,14 +2150,17 @@ const Dispatch = ({
|
|||||||
}
|
}
|
||||||
// "All Active Routes": the header must reflect exactly what the list/map
|
// "All Active Routes": the header must reflect exactly what the list/map
|
||||||
// shows — the in-progress orders and the riders working them — NOT the whole
|
// shows — the in-progress orders and the riders working them — NOT the whole
|
||||||
// day's totals. We count only active deliveries (and `visibleRiders`, which
|
// day's totals. Source from `activeViewRiders`, the SAME sticky-cached list
|
||||||
// is already gated to active-order riders) so the tiles can't disagree with
|
// that <ActiveSection> renders as cards (see `visibleRiders={activeViewRiders}`
|
||||||
// the list/map below.
|
// below) — not `visibleRiders`, which additionally requires a rider to be
|
||||||
|
// present in the independently-polled GPS-log feed with status 'active'/
|
||||||
|
// 'pending'. That extra join rarely resolves, which is why this tile used to
|
||||||
|
// show 0 riders even while real rider cards were on screen.
|
||||||
if (isAllActiveView) {
|
if (isAllActiveView) {
|
||||||
const activeOrders = allOrders.filter(isActiveDelivery);
|
const activeOrders = activeViewRiders.flatMap((r) => r.orders);
|
||||||
return {
|
return {
|
||||||
orders: activeOrders.length,
|
orders: activeOrders.length,
|
||||||
riders: visibleRiders.length,
|
riders: activeViewRiders.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'
|
||||||
@@ -2170,7 +2173,7 @@ const Dispatch = ({
|
|||||||
profit: stats.totalProfit,
|
profit: stats.totalProfit,
|
||||||
label: 'Total Fleet'
|
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
|
// 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
|
||||||
@@ -3253,9 +3256,13 @@ const Dispatch = ({
|
|||||||
const routes = [];
|
const routes = [];
|
||||||
const zoneRiderIds = focusedZone ? new Set(focusedZone.riders.map((zr) => String(zr.rider_id))) : null;
|
const zoneRiderIds = focusedZone ? new Set(focusedZone.riders.map((zr) => String(zr.rider_id))) : null;
|
||||||
if (hidePlanned) return routes;
|
if (hidePlanned) return routes;
|
||||||
// visibleRiders === riders in every view except "All Active Routes", where
|
// In "All Active Routes" draw for exactly the riders shown as cards
|
||||||
// it's pre-filtered to riders whose live GPS is currently active.
|
// (activeViewRiders) — not `visibleRiders`, which additionally requires a
|
||||||
visibleRiders.forEach(r => {
|
// rider to be present in the independently-polled GPS-log feed with status
|
||||||
|
// 'active'/'pending'. That join rarely resolves, which left the map with
|
||||||
|
// no polyline for a rider whose active-order marker/card was clearly
|
||||||
|
// visible and clickable. Every other view keeps using `riders` (unfiltered).
|
||||||
|
(isAllActiveView ? activeViewRiders : riders).forEach(r => {
|
||||||
const isActive = activeRiders.has(r.id);
|
const isActive = activeRiders.has(r.id);
|
||||||
if (focusedRider && focusedRider.id !== r.id) return;
|
if (focusedRider && focusedRider.id !== r.id) return;
|
||||||
if (focusedKitchen && !focusedKitchen.riders.has(r.id)) return;
|
if (focusedKitchen && !focusedKitchen.riders.has(r.id)) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user