updates on the active page section
This commit is contained in:
@@ -30,8 +30,8 @@ const ActiveSection = ({
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.filter((o) => String(o.orderstatus || '').toLowerCase() === 'active')
|
.filter((o) => String(o.orderstatus || '').toLowerCase() === 'active')
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
const mA = calculateEstMeters(a.rider_id, a) ?? Infinity;
|
const mA = calculateEstMeters(a.rider_id || a.userid, a) ?? Infinity;
|
||||||
const mB = calculateEstMeters(b.rider_id, b) ?? Infinity;
|
const mB = calculateEstMeters(b.rider_id || b.userid, b) ?? Infinity;
|
||||||
return mA - mB;
|
return mA - mB;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ const ActiveSection = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const renderActiveDeliveryCard = (o, i) => {
|
const renderActiveDeliveryCard = (o, i) => {
|
||||||
const rid = o.rider_id;
|
const rid = o.rider_id || o.userid;
|
||||||
const rider = riders.find((r) => String(r.id) === String(rid));
|
const rider = riders.find((r) => String(r.id) === String(rid));
|
||||||
const color = getRiderColor(rid);
|
const color = getRiderColor(rid);
|
||||||
const statusStyle = getStatusStyle(o.orderstatus);
|
const statusStyle = getStatusStyle(o.orderstatus);
|
||||||
|
|||||||
@@ -1702,7 +1702,7 @@ 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) {
|
||||||
const activeOrders = allViewOrders.filter(isActiveDelivery);
|
const activeOrders = allViewOrders.filter((o) => String(o?.orderstatus || '').toLowerCase() === 'active');
|
||||||
return {
|
return {
|
||||||
orders: activeOrders.length,
|
orders: activeOrders.length,
|
||||||
riders: visibleRiders.length,
|
riders: visibleRiders.length,
|
||||||
@@ -1725,7 +1725,7 @@ const Dispatch = ({
|
|||||||
// the header (RIDER DISPATCH title + Active Fleet badge + order/rider tiles)
|
// the header (RIDER DISPATCH title + Active Fleet badge + order/rider tiles)
|
||||||
// is hidden so the "No active deliveries" empty state stands on its own.
|
// is hidden so the "No active deliveries" empty state stands on its own.
|
||||||
const activeDeliveryCount = useMemo(
|
const activeDeliveryCount = useMemo(
|
||||||
() => (isAllActiveView ? allViewOrders.filter(isActiveDelivery).length : 0),
|
() => (isAllActiveView ? allViewOrders.filter((o) => String(o?.orderstatus || '').toLowerCase() === 'active').length : 0),
|
||||||
[isAllActiveView, allViewOrders]
|
[isAllActiveView, allViewOrders]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2462,7 +2462,7 @@ const Dispatch = ({
|
|||||||
html: `<div class="kitchen-mark${focused ? ' is-focused' : ''}">${(name || 'K').charAt(0).toUpperCase()}</div>`
|
html: `<div class="kitchen-mark${focused ? ' is-focused' : ''}">${(name || 'K').charAt(0).toUpperCase()}</div>`
|
||||||
});
|
});
|
||||||
|
|
||||||
const getRiderColor = (rid) => riders.find(r => r.id === rid)?.color || '#475569';
|
const getRiderColor = (rid) => riders.find(r => String(r.id) === String(rid))?.color || '#475569';
|
||||||
|
|
||||||
const calculateEstMeters = (riderId, order) => {
|
const calculateEstMeters = (riderId, order) => {
|
||||||
if (!riderId || !order || !hasValidDrop(order)) return null;
|
if (!riderId || !order || !hasValidDrop(order)) return null;
|
||||||
@@ -3872,6 +3872,7 @@ const Dispatch = ({
|
|||||||
so the empty state isn't topped by a "0 orders / 0 riders" header. */}
|
so the empty state isn't topped by a "0 orders / 0 riders" header. */}
|
||||||
{!focusedRider && !(isAllActiveView && activeDeliveryCount === 0) && (
|
{!focusedRider && !(isAllActiveView && activeDeliveryCount === 0) && (
|
||||||
<div className="sb-header">
|
<div className="sb-header">
|
||||||
|
{!isAllActiveView && (
|
||||||
<div className="sb-header-top">
|
<div className="sb-header-top">
|
||||||
<div className="sb-header-title">
|
<div className="sb-header-title">
|
||||||
<span className="sb-title-bar" aria-hidden="true" />
|
<span className="sb-title-bar" aria-hidden="true" />
|
||||||
@@ -3882,6 +3883,7 @@ const Dispatch = ({
|
|||||||
{activeStats.label}
|
{activeStats.label}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="sb-header-tiles">
|
<div className="sb-header-tiles">
|
||||||
<div className="sb-tile sb-tile-orders">
|
<div className="sb-tile sb-tile-orders">
|
||||||
@@ -4449,7 +4451,7 @@ const Dispatch = ({
|
|||||||
{/* Hide the panel title in the Active view when there are no
|
{/* Hide the panel title in the Active view when there are no
|
||||||
in-progress deliveries, so the empty state isn't topped by
|
in-progress deliveries, so the empty state isn't topped by
|
||||||
an "Active rider dispatch" heading. */}
|
an "Active rider dispatch" heading. */}
|
||||||
{!(isAllActiveView && activeDeliveryCount === 0) && (
|
{!isAllActiveView && (
|
||||||
<div className="ph">{
|
<div className="ph">{
|
||||||
viewMode === 'zones' ? 'Zone dispatch' :
|
viewMode === 'zones' ? 'Zone dispatch' :
|
||||||
viewMode === 'kitchens' ? 'Kitchen dispatch' :
|
viewMode === 'kitchens' ? 'Kitchen dispatch' :
|
||||||
|
|||||||
Reference in New Issue
Block a user