Migrate console off jupiter.nearle.app to the Doormile Express API
Retires REACT_APP_URL/URL2/URL3 in favor of REACT_APP_DOORMILE_URL across every page (orders, deliveries, riders, tenants, pricing, profile, reports, dispatch). Fixes several field-mapping and envelope-check bugs found along the way, most notably that /admin/milers/:id routes (block, assign-vehicle, edit, notify) key off milerprofileid, not userid, and that a miler's real fields are phone/availabilitystatus/displayname, not contactno/status/ firstname+lastname (confirmed against a live read-only session). Also fixes several silent-failure bugs uncovered during that audit: order creation and order cancellation showed a success toast but gave no feedback at all on failure (createorder1.js had a dead notifyadmin() call that left the loading spinner stuck forever on every failed submit), and Tenants.js's pricing/profile updates never surfaced a failed response to the operator. The AI dispatch optimiser (routes.workolik.com/routemate.workolik.com) and its jupiter.nearle.app delivery-commit call remain untouched by design — separate solver service with no equivalent in the new API.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import axios from 'axios';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
// material-ui
|
||||
@@ -59,7 +58,6 @@ import PageHeader from 'components/nearle_components/PageHeader';
|
||||
import StatCard from 'components/nearle_components/StatCard';
|
||||
import { OrdersTableSkeleton } from '../orders/OrdersTableSkeleton';
|
||||
import RidersRoutes from './RidersRoutes';
|
||||
import { OpenToast } from 'components/third-party/OpenToast';
|
||||
import { MobileCard, MobileCardList, MobileField, MobileFieldGrid } from 'components/nearle_components/MobileCard';
|
||||
|
||||
// ============================================================================
|
||||
@@ -242,79 +240,22 @@ export default function RidersSummary() {
|
||||
);
|
||||
}, [rows]);
|
||||
|
||||
// ==============================|| per-rider tenant breakdown ||============================== //
|
||||
const fetchTenantSummary = async (riderUserid) => {
|
||||
// No per-rider tenant-breakdown endpoint in the new API.
|
||||
const fetchTenantSummary = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const tenantRes = await axios.get(
|
||||
`${process.env.REACT_APP_URL}/deliveries/getreportsummary/?&fromdate=${startdate}&todate=${enddate}&userid=${riderUserid}`
|
||||
);
|
||||
setTenantData(tenantRes.data.details);
|
||||
} catch (error) {
|
||||
console.log('tenantRes', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
setTenantData(null);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
// ==============================|| rider planned route (for map) ||============================== //
|
||||
// Pulls every delivery the rider was assigned over the page's date range, then
|
||||
// emits an ordered waypoint list sorted by `step` (the planning sequence). The
|
||||
// map dialog renders this as the rider's PLANNED route — the path the
|
||||
// optimizer told them to follow — not their actual GPS trail.
|
||||
const getuserdeliverylogs = async (userid) => {
|
||||
// /admin/consignments has no documented per-row schema (lat/lng/step/
|
||||
// customer fields aren't shown anywhere in the doc), so building a planned
|
||||
// route from it would be guesswork that risks plotting wrong pins on the
|
||||
// map. Degrades to an empty route instead.
|
||||
const getuserdeliverylogs = async () => {
|
||||
setRouteLoading(true);
|
||||
try {
|
||||
const url =
|
||||
`${process.env.REACT_APP_URL}/deliveries/getdeliveries/` +
|
||||
`?applocationid=${appId}` +
|
||||
`&status=all` +
|
||||
`&fromdate=${startdate}` +
|
||||
`&todate=${enddate}` +
|
||||
`&pageno=1` +
|
||||
`&pagesize=200` +
|
||||
`&keyword=` +
|
||||
`&tenantid=` +
|
||||
`&locationid=` +
|
||||
`&userid=${userid}`;
|
||||
const response = await axios.get(url);
|
||||
const rowsRaw = response?.data?.details || [];
|
||||
const toNum = (v) => {
|
||||
const n = Number(v);
|
||||
return Number.isFinite(n) ? n : null;
|
||||
};
|
||||
const planned = rowsRaw
|
||||
.map((o) => {
|
||||
const dropLat = toNum(o.droplat ?? o.deliverylat);
|
||||
const dropLng = toNum(o.droplon ?? o.deliverylong);
|
||||
const pickLat = toNum(o.pickuplat ?? o.pickuplatitude);
|
||||
const pickLng = toNum(o.pickuplon ?? o.pickuplong ?? o.picklongitude);
|
||||
if (dropLat == null || dropLng == null) return null;
|
||||
return {
|
||||
step: Number(o.step) || 0,
|
||||
orderid: o.orderid,
|
||||
deliveryid: o.deliveryid,
|
||||
customer: o.deliverycustomer || o.customername || `Order ${o.orderid}`,
|
||||
address: o.deliveryaddress || o.deliverysuburb || '',
|
||||
dropLat,
|
||||
dropLng,
|
||||
pickLat: pickLat ?? null,
|
||||
pickLng: pickLng ?? null,
|
||||
// Expected delivery clock — used as a label under the step pin so
|
||||
// the operator can sanity-check sequencing without clicking each
|
||||
// marker.
|
||||
expectedTime: o.expecteddeliverytime || null
|
||||
};
|
||||
})
|
||||
.filter(Boolean)
|
||||
.sort((a, b) => a.step - b.step);
|
||||
setLogDetails(planned);
|
||||
} catch (err) {
|
||||
OpenToast(err?.message, 'error', 2000);
|
||||
setLogDetails([]);
|
||||
} finally {
|
||||
setRouteLoading(false);
|
||||
}
|
||||
setLogDetails([]);
|
||||
setRouteLoading(false);
|
||||
};
|
||||
|
||||
// Total Amount sum (preserved from legacy bottom bar).
|
||||
|
||||
Reference in New Issue
Block a user