fix
All checks were successful
Build And Deploy Main / build-and-deploy (push) Successful in 31s

This commit is contained in:
2026-03-10 14:41:52 -04:00
parent 2bc56d7836
commit 1d38bac7fe

View File

@@ -28,6 +28,7 @@ const RouteView = () => {
const [isSavingRouteStatus, setIsSavingRouteStatus] = useState(false);
const [latestRouteForStatus, setLatestRouteForStatus] = useState(undefined);
const [routeSnapshot, setRouteSnapshot] = useState(undefined);
const [customerMetaById, setCustomerMetaById] = useState(new Map());
const paramsQuery = new URLSearchParams(window.location.search);
const scheduleDate = paramsQuery.get('dateSchedule');
@@ -42,7 +43,22 @@ const RouteView = () => {
{ value: ROUTE_STATUS.SIGN_OFF, label: 'Signed Off' },
{ value: ROUTE_STATUS.UNEXPECTED_ABSENT, label: 'Unexpected Absent' },
];
const routeForStatusView = latestRouteForStatus || currentRoute;
const mergeRouteCustomerMeta = (route) => {
if (!route || !Array.isArray(route?.route_customer_list) || customerMetaById.size === 0) {
return route;
}
return Object.assign({}, route, {
route_customer_list: route.route_customer_list.map((customerInRoute) => {
const customerMeta = customerMetaById.get(customerInRoute?.customer_id);
if (!customerMeta) return customerInRoute;
return Object.assign({}, customerInRoute, {
customer_program_type: customerMeta.program_type || '',
customer_pay_source: customerMeta.pay_source || ''
});
})
});
};
const routeForStatusView = mergeRouteCustomerMeta(latestRouteForStatus || routeSnapshot || currentRoute);
const routeForAssignmentView = routeSnapshot || currentRoute;
const closeModal = () => {
setShowVehicleDetails(false);
@@ -146,6 +162,23 @@ const RouteView = () => {
});
}, [currentRoute?.id, params?.id]);
useEffect(() => {
CustomerService.getAllCustomers()
.then((res) => {
const nextMap = new Map();
(res?.data || []).forEach((customer) => {
nextMap.set(customer?.id, {
program_type: customer?.program_type || '',
pay_source: customer?.pay_source || ''
});
});
setCustomerMetaById(nextMap);
})
.catch(() => {
setCustomerMetaById(new Map());
});
}, []);
useEffect(() => {
if (!currentRoute?.driver || currentDriver?.id) {
setFallbackDriver(undefined);