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))}
@@ -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.
+ )}
+