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

This commit is contained in:
2026-03-09 15:28:15 -04:00
parent dd3a690cb4
commit 3d78f2beda

View File

@@ -81,27 +81,37 @@ const RouteReportWithSignature = () => {
.toLowerCase() .toLowerCase()
.replace(/[^a-z0-9]/g, ''); .replace(/[^a-z0-9]/g, '');
// Include current route checklist, and also paired same-day route checklist. const normalizedCurrentRouteName = currentRoute?.name?.toLowerCase()?.replaceAll(' ', '');
// This keeps inspection checks visible whether results were saved on inbound or outbound. const checklistSourceRoutes = [
const pairedRoute = getRelatedInboundOutboundRoutesForThisView(currentRoute?.type) currentRoute,
?.find((route) => ...(getRelatedInboundOutboundRoutesForThisView(currentRoute?.type) || []).filter((route) =>
route?.schedule_date === currentRoute?.schedule_date && route?.schedule_date === currentRoute?.schedule_date &&
route?.name?.toLowerCase()?.replaceAll(' ', '') === currentRoute?.name?.toLowerCase()?.replaceAll(' ', '') route?.name?.toLowerCase()?.replaceAll(' ', '') === normalizedCurrentRouteName &&
); ['inbound', 'outbound'].includes(route?.type)
const checklistResult = [ )
...(currentRoute?.checklist_result || []), ].filter(Boolean);
...(pairedRoute?.checklist_result || [])
]; const checklistItemsMap = new Map();
const getChecklistStatus = (itemKey) => { checklistSourceRoutes.forEach((route) => {
const normalizedItemKey = normalizeChecklistText(itemKey); (route?.checklist_result || []).forEach((item) => {
const item = checklistResult.find((c) => { const displayLabel = item?.item || item?.label || item?.key || '';
const candidates = [c?.key, c?.label, c?.item] const normalizedKey = normalizeChecklistText(displayLabel);
.map(normalizeChecklistText) if (!normalizedKey) return;
.filter(Boolean); const current = checklistItemsMap.get(normalizedKey) || {
return candidates.some((candidate) => candidate.includes(normalizedItemKey)); label: displayLabel,
inspected: false
};
checklistItemsMap.set(normalizedKey, {
label: current.label || displayLabel,
inspected: current.inspected || item?.result === true || item?.checked === true
});
}); });
return (item?.result === true || item?.checked === true) ? '✓' : ''; });
}; const checklistItems = Array.from(checklistItemsMap.values());
const checklistRows = [];
for (let i = 0; i < checklistItems.length; i += 3) {
checklistRows.push(checklistItems.slice(i, i + 3));
}
const sortedRouteCustomers = [...(currentRoute?.route_customer_list || [])].sort((a, b) => { const sortedRouteCustomers = [...(currentRoute?.route_customer_list || [])].sort((a, b) => {
const aOrder = Number(a?.customer_pickup_order); const aOrder = Number(a?.customer_pickup_order);
@@ -340,38 +350,32 @@ const RouteReportWithSignature = () => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> {checklistRows.length === 0 && (
<td>Tires/Rims<span className="bilingual-label">车胎/车圈</span></td> <tr>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('tires') || getChecklistStatus('Tires')}</td> <td colSpan={6} style={{ textAlign: 'center' }}>No checklist data</td>
<td>Door(s)<span className="bilingual-label">车门</span></td> </tr>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('door') || getChecklistStatus('Door')}</td> )}
<td>Seat/Seat-belt<span className="bilingual-label">座位/安全带</span></td> {checklistRows.map((row, rowIndex) => (
<td style={{ textAlign: 'center' }}>{getChecklistStatus('seat') || getChecklistStatus('Seat')}</td> <tr key={`checklist-row-${rowIndex}`}>
</tr> {[0, 1, 2].map((cellIndex) => {
<tr> const item = row[cellIndex];
<td>Mirrors/Windows<span className="bilingual-label">镜子/窗户</span></td> if (!item) {
<td style={{ textAlign: 'center' }}>{getChecklistStatus('mirror') || getChecklistStatus('Mirror') || getChecklistStatus('window') || getChecklistStatus('Window')}</td> return (
<td>Light(s)<span className="bilingual-label">车灯</span></td> <React.Fragment key={`checklist-empty-${rowIndex}-${cellIndex}`}>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('light') || getChecklistStatus('Light')}</td> <td></td>
<td>Lift (wheelchair)<span className="bilingual-label">轮椅起降器</span></td> <td></td>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('lift') || getChecklistStatus('Lift')}</td> </React.Fragment>
</tr> );
<tr> }
<td>Emergency Folder<span className="bilingual-label">紧急情况信息夹</span></td> return (
<td style={{ textAlign: 'center' }}>{getChecklistStatus('emergency') || getChecklistStatus('Emergency')}</td> <React.Fragment key={`checklist-item-${rowIndex}-${cellIndex}`}>
<td>Tie Down<span className="bilingual-label">固定绳索</span></td> <td>{item.label}</td>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('tie') || getChecklistStatus('Tie')}</td> <td style={{ textAlign: 'center' }}>{item.inspected ? '✓' : ''}</td>
<td>Heater/AC<span className="bilingual-label">暖气/冷气</span></td> </React.Fragment>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('heater') || getChecklistStatus('Heater') || getChecklistStatus('ac') || getChecklistStatus('AC')}</td> );
</tr> })}
<tr> </tr>
<td>Fire Extinguisher<span className="bilingual-label">灭火器</span></td> ))}
<td style={{ textAlign: 'center' }}>{getChecklistStatus('fire') || getChecklistStatus('Fire') || getChecklistStatus('extinguisher')}</td>
<td>Body<span className="bilingual-label">车身</span></td>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('body') || getChecklistStatus('Body')}</td>
<td>Coolant<span className="bilingual-label">冷冻液</span></td>
<td style={{ textAlign: 'center' }}>{getChecklistStatus('coolant') || getChecklistStatus('Coolant')}</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>