mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 21:48:18 +00:00
fix
This commit is contained in:
@@ -116,11 +116,25 @@ const vehicleLabel = (record: FirstMileRecord) => {
|
||||
const isAssigned = (record: FirstMileRecord) =>
|
||||
Boolean(record.vehicleId) || Boolean(record.vehicleAssignments?.length);
|
||||
|
||||
/** Container numbers on a booking, in line order (skips lines without one). */
|
||||
const bookingContainerNumbers = (record: FirstMileRecord): string[] =>
|
||||
(record.booking?.bookingContainers ?? [])
|
||||
.map((c) => c.containerNumber)
|
||||
.filter((n): n is string => Boolean(n));
|
||||
/** Real per-physical-container numbers on a booking, in order. Prefers each
|
||||
* line's `units` (the actual numbers) over the line-level number (often a
|
||||
* "TBD-…" placeholder). One entry per physical container, for per-truck prefill. */
|
||||
const bookingContainerNumbers = (record: FirstMileRecord): string[] => {
|
||||
const out: string[] = [];
|
||||
const real = (n?: string | null): n is string =>
|
||||
Boolean(n) && !/^TBD/i.test(n!.trim());
|
||||
for (const c of record.booking?.bookingContainers ?? []) {
|
||||
const units = [...(c.units ?? [])].sort(
|
||||
(a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0),
|
||||
);
|
||||
if (units.length) {
|
||||
for (const u of units) if (real(u.containerNumber)) out.push(u.containerNumber!);
|
||||
} else if (real(c.containerNumber)) {
|
||||
out.push(c.containerNumber!);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
/** Progress stages of the first-mile pickup workflow, for the detail stepper. */
|
||||
const computeFirstMileSteps = (record: FirstMileRecord): LastMileStepState[] => {
|
||||
|
||||
@@ -128,11 +128,25 @@ const requiredVehicles = (record: LastMileRecord) => {
|
||||
return n > 0 ? Math.ceil(n / CONTAINERS_PER_VEHICLE) : 0;
|
||||
};
|
||||
|
||||
/** Container numbers on a booking, in line order (skips lines without one). */
|
||||
const bookingContainerNumbers = (record: LastMileRecord): string[] =>
|
||||
(record.booking?.bookingContainers ?? [])
|
||||
.map((c) => c.containerNumber)
|
||||
.filter((n): n is string => Boolean(n));
|
||||
/** Real per-physical-container numbers on a booking, in order. Prefers each
|
||||
* line's `units` (the actual numbers) over the line-level number (often a
|
||||
* "TBD-…" placeholder). One entry per physical container, for per-truck prefill. */
|
||||
const bookingContainerNumbers = (record: LastMileRecord): string[] => {
|
||||
const out: string[] = [];
|
||||
const real = (n?: string | null): n is string =>
|
||||
Boolean(n) && !/^TBD/i.test(n!.trim());
|
||||
for (const c of record.booking?.bookingContainers ?? []) {
|
||||
const units = [...(c.units ?? [])].sort(
|
||||
(a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0),
|
||||
);
|
||||
if (units.length) {
|
||||
for (const u of units) if (real(u.containerNumber)) out.push(u.containerNumber!);
|
||||
} else if (real(c.containerNumber)) {
|
||||
out.push(c.containerNumber!);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
/** Container badges for a booking: the container number when known, else the
|
||||
* type × quantity. */
|
||||
|
||||
Reference in New Issue
Block a user