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

View File

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

View File

@@ -1024,19 +1024,29 @@ const RoutesDashboard = () => {
// setSelectedDriver(undefined);
}
const cleanupSchedule = () => {
const routesToDelete = deleteRouteType === 'inbound'
? (tmrInboundRoutes || [])
: deleteRouteType === 'outbound'
? (tmrOutboundRoutes || [])
: (allTomorrowRoutes || []);
routesToDelete.forEach((route) => {
TransRoutesService.deleteRoute(route.id);
const cleanupSchedule = async () => {
const routesToDelete = (routesForShowing || []).filter((route) => {
if (deleteRouteType === 'inbound') return route?.type === 'inbound';
if (deleteRouteType === 'outbound') return route?.type === 'outbound';
return true;
});
setTimeout(() => {
const deleteRequests = routesToDelete
.map((route) => route?.id || route?._id)
.filter(Boolean)
.map((routeId) => TransRoutesService.deleteRoute(routeId));
await Promise.allSettled(deleteRequests);
closeDeleteModal();
window.location.reload();
}, 1000)
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 = () => {