From cad4b84b8c8c3f4905103c0e16ff26031756899f Mon Sep 17 00:00:00 2001 From: natib21 Date: Fri, 3 Jul 2026 21:57:53 +0000 Subject: [PATCH] mile --- .../src/pages/operations/LastMilePage.tsx | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx b/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx index c3c59ca58..f3f290304 100644 --- a/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx +++ b/apps/edr-freight-web/backoffice/src/pages/operations/LastMilePage.tsx @@ -324,7 +324,10 @@ const tripSlipRows = ( : vehicle.vehicleId, ], ["Driver", vehicle.vehicle?.assignedDriverName || "—"], - ["Container(s)", vehicle.containerNumber || "—"], + [ + "Container(s)", + vehicle.containerNumber || bookingContainerNumbers(record).join(", ") || "—", + ], ["Distance (KM)", vehicle.distanceKm != null ? String(vehicle.distanceKm) : "—"], ] : [ @@ -469,7 +472,7 @@ const buildTripSlipHtml = (record: LastMileRecord, vehicle?: TripSlipVehicle | n .ring-inner span { font-size: 9px; font-weight: 700; letter-spacing: 1px; } .ring-inner strong { font-size: 13px; font-weight: 800; } - +

EDR Freight

Last Mile Trip Slip

${escapeHtml(bookingRef(record))}${escapeHtml(requestedDate(record))}
${rows}
@@ -946,16 +949,16 @@ const LastMilePage = () => { }; const handlePrintTripSlip = (record: LastMileRecord) => { + // Always open the picker so the operator chooses which truck to print. setTripSlipRecord(record); - const assigns = record.vehicleAssignments ?? []; - if (assigns.length > 1) { - // Multiple trucks → let the operator pick which one to print. - setTripSlipVehicleId(null); - setTripSlipSelectOpen(true); - } else { - setTripSlipVehicleId(assigns[0]?.vehicleId ?? null); - setTripSlipOpen(true); - } + setTripSlipVehicleId(null); + setTripSlipSelectOpen(true); + }; + + const printBookingSlip = () => { + setTripSlipVehicleId(null); + setTripSlipSelectOpen(false); + setTripSlipOpen(true); }; const chooseTripSlipVehicle = (vehicleId: string) => { @@ -1016,6 +1019,15 @@ const LastMilePage = () => { } win.document.write(buildTripSlipHtml(tripSlipRecord, tripSlipVehicle)); win.document.close(); + win.focus(); + // Explicit print after the doc paints (onload can miss with document.write). + setTimeout(() => { + try { + win.print(); + } catch { + /* window may have been closed */ + } + }, 250); }; const columns = useMemo((): ColumnDef[] => { @@ -1749,7 +1761,8 @@ const LastMilePage = () => { > - {tripSlipRecord ? bookingRef(tripSlipRecord) : ""} has multiple trucks — choose one. + {tripSlipRecord ? bookingRef(tripSlipRecord) : ""} — choose a truck to print its slip + (vehicle, driver, container). {(tripSlipRecord?.vehicleAssignments ?? []).map((a) => { const v = a.vehicle; @@ -1772,6 +1785,12 @@ const LastMilePage = () => { ); })} + {(tripSlipRecord?.vehicleAssignments?.length ?? 0) === 0 && ( + No vehicles assigned yet. + )} +