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

This commit is contained in:
2026-03-16 10:01:13 -04:00
parent 0c7abd3466
commit 37a6f383d7
3 changed files with 31 additions and 35 deletions

View File

@@ -11,7 +11,6 @@ import TransRoutes from './components/trans-routes/TransRoutes';
import RoutesDashboard from "./components/trans-routes/RoutesDashboard"; import RoutesDashboard from "./components/trans-routes/RoutesDashboard";
import RouteView from "./components/trans-routes/RouteView"; import RouteView from "./components/trans-routes/RouteView";
import RouteEdit from "./components/trans-routes/RouteEdit"; import RouteEdit from "./components/trans-routes/RouteEdit";
import RoutesSchedule from "./components/trans-routes/RoutesSchedule";
import CreateVehicle from "./components/vehicles/CreateVehicle"; import CreateVehicle from "./components/vehicles/CreateVehicle";
import UpdateVehicle from "./components/vehicles/UpdateVehicle"; import UpdateVehicle from "./components/vehicles/UpdateVehicle";
import AddVehicleInspection from "./components/vehicles/AddVehicleInspection"; import AddVehicleInspection from "./components/vehicles/AddVehicleInspection";
@@ -211,7 +210,7 @@ function App() {
<Route path="dashboard" element={<RoutesDashboard/>} /> <Route path="dashboard" element={<RoutesDashboard/>} />
<Route path=":id" element={<RouteView/>} /> <Route path=":id" element={<RouteView/>} />
<Route path="edit/:id" element={<RouteEdit/>} /> <Route path="edit/:id" element={<RouteEdit/>} />
<Route path="schedule" element={<RoutesSchedule />} /> <Route path="schedule" element={<RoutesDashboard/>} />
<Route path="history" element={<RoutesHistory />} /> <Route path="history" element={<RoutesHistory />} />
<Route path="templates" element={<RouteTemplatesList />} /> <Route path="templates" element={<RouteTemplatesList />} />
<Route path="templates/edit/:id" element={<RouteTemplateEdit />} /> <Route path="templates/edit/:id" element={<RouteTemplateEdit />} />

View File

@@ -24,7 +24,6 @@ const RouteReportWithSignature = () => {
const [directorSignature, setDirectorSignature] = useState(undefined); const [directorSignature, setDirectorSignature] = useState(undefined);
const [customerMetaById, setCustomerMetaById] = useState(new Map()); const [customerMetaById, setCustomerMetaById] = useState(new Map());
const [customerMetaByName, setCustomerMetaByName] = useState(new Map());
const site = EventsService.site; const site = EventsService.site;
@@ -130,28 +129,17 @@ const RouteReportWithSignature = () => {
CustomerService.getAllCustomers() CustomerService.getAllCustomers()
.then((res) => { .then((res) => {
const nextMap = new Map(); const nextMap = new Map();
const nextByNameMap = new Map();
(res?.data || []).forEach((customer) => { (res?.data || []).forEach((customer) => {
const meta = { const meta = {
program_type: customer?.program_type || '', program_type: customer?.program_type || '',
pay_source: customer?.pay_source || '', pay_source: customer?.pay_source || ''
notes_for_driver: customer?.notes_for_driver || ''
}; };
nextMap.set(customer?.id, meta); nextMap.set(customer?.id, meta);
const nameKey = (customer?.name || '').toString().trim().toLowerCase();
if (nameKey) {
const previous = nextByNameMap.get(nameKey);
if (!previous || (customer?.status || '').toString().toLowerCase() === 'active') {
nextByNameMap.set(nameKey, meta);
}
}
}); });
setCustomerMetaById(nextMap); setCustomerMetaById(nextMap);
setCustomerMetaByName(nextByNameMap);
}) })
.catch(() => { .catch(() => {
setCustomerMetaById(new Map()); setCustomerMetaById(new Map());
setCustomerMetaByName(new Map());
}); });
}, []); }, []);
const normalizeChecklistText = (value = '') => const normalizeChecklistText = (value = '') =>
@@ -243,12 +231,11 @@ const RouteReportWithSignature = () => {
return { y: '', n: '✗' }; return { y: '', n: '✗' };
}; };
const getRouteNoteToDriverText = (customerId, ...customerCandidates) => { const getTransferToRouteText = (...customerCandidates) => {
const profileNote = (customerMetaById.get(customerId)?.notes_for_driver || '').toString().trim(); for (const customerCandidate of customerCandidates) {
if (profileNote) return profileNote; const transferToRoute = (customerCandidate?.customer_transfer_to_route || '').toString().trim();
const firstCustomerName = (customerCandidates?.[0]?.customer_name || '').toString().trim().toLowerCase(); if (transferToRoute) return transferToRoute;
const profileNoteByName = (customerMetaByName.get(firstCustomerName)?.notes_for_driver || '').toString().trim(); }
if (profileNoteByName) return profileNoteByName;
return ''; return '';
}; };
@@ -378,7 +365,7 @@ const RouteReportWithSignature = () => {
const customerInOtherRoute = otherRouteWithThisCustomer?.route_customer_list?.find(cust => cust?.customer_id === customer?.customer_id); const customerInOtherRoute = otherRouteWithThisCustomer?.route_customer_list?.find(cust => cust?.customer_id === customer?.customer_id);
const otherOutboundRoute = getOtherOutboundRouteWithThisCustomer(customer?.customer_id); const otherOutboundRoute = getOtherOutboundRouteWithThisCustomer(customer?.customer_id);
const attendanceDisplay = getAttendanceDisplayByReportLogic(customer, relativeRouteCustomer, customerInOtherRoute); const attendanceDisplay = getAttendanceDisplayByReportLogic(customer, relativeRouteCustomer, customerInOtherRoute);
const routeNoteText = getRouteNoteToDriverText(customer?.customer_id, customer, relativeRouteCustomer, customerInOtherRoute); const routeTransferToRouteText = getTransferToRouteText(customer, relativeRouteCustomer, customerInOtherRoute);
return ( return (
<tr key={index}> <tr key={index}>
@@ -426,7 +413,7 @@ const RouteReportWithSignature = () => {
: ''))} : ''))}
</td> </td>
<td> <td>
{routeNoteText && <div>{routeNoteText}</div>} {routeTransferToRouteText && <div>{routeTransferToRouteText}</div>}
{customer?.customer_type !== CUSTOMER_TYPE.MEMBER && <div>{CUSTOMER_TYPE_TEXT[customer?.customer_type]}</div>} {customer?.customer_type !== CUSTOMER_TYPE.MEMBER && <div>{CUSTOMER_TYPE_TEXT[customer?.customer_type]}</div>}
{!relativeRouteCustomer && otherRouteWithThisCustomer && ( {!relativeRouteCustomer && otherRouteWithThisCustomer && (
<div>{`${currentRoute?.type === 'inbound' ? 'Switch to Route ' : 'Switch from Route '} ${otherRouteWithThisCustomer?.name}`}</div> <div>{`${currentRoute?.type === 'inbound' ? 'Switch to Route ' : 'Switch from Route '} ${otherRouteWithThisCustomer?.name}`}</div>

View File

@@ -1024,19 +1024,29 @@ const RoutesDashboard = () => {
// setSelectedDriver(undefined); // setSelectedDriver(undefined);
} }
const cleanupSchedule = () => { const cleanupSchedule = async () => {
const routesToDelete = deleteRouteType === 'inbound' const routesToDelete = (routesForShowing || []).filter((route) => {
? (tmrInboundRoutes || []) if (deleteRouteType === 'inbound') return route?.type === 'inbound';
: deleteRouteType === 'outbound' if (deleteRouteType === 'outbound') return route?.type === 'outbound';
? (tmrOutboundRoutes || []) return true;
: (allTomorrowRoutes || []);
routesToDelete.forEach((route) => {
TransRoutesService.deleteRoute(route.id);
}); });
setTimeout(() => {
closeDeleteModal(); const deleteRequests = routesToDelete
window.location.reload(); .map((route) => route?.id || route?._id)
}, 1000) .filter(Boolean)
.map((routeId) => TransRoutesService.deleteRoute(routeId));
await Promise.allSettled(deleteRequests);
closeDeleteModal();
const selectedDateString = getDateString(dateSelected);
if (selectedDateString === getDateString(new Date())) {
dispatch(fetchAllRoutes());
} else if (dateSelected > new Date()) {
dispatch(fetchAllTomorrowRoutes({ dateText: moment(dateSelected).format('MM/DD/YYYY') }));
} else {
dispatch(fetchAllHistoryRoutes({ dateText: getDateString(dateSelected) }));
}
} }
const closeDeleteModal = () => { const closeDeleteModal = () => {