mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
fix
This commit is contained in:
@@ -664,6 +664,35 @@ const FirstMilePage = () => {
|
||||
return opts;
|
||||
}, [vehicleOptions, activeRecord]);
|
||||
|
||||
// Full booking (with container units) for the assign modal's container dropdown.
|
||||
// Fetched on open so container numbers show regardless of what the list embeds.
|
||||
const { data: assignBooking } = useQuery({
|
||||
queryKey: activeRecord?.bookingId
|
||||
? QUERY_KEYS.BOOKINGS.byId(activeRecord.bookingId)
|
||||
: ["bookings", "detail", "none"],
|
||||
queryFn: () => bookingsService.getById(activeRecord!.bookingId),
|
||||
enabled: assignOpen && !bulkMode && Boolean(activeRecord?.bookingId),
|
||||
});
|
||||
|
||||
// Container-number options for the dropdown = the booking's real per-container
|
||||
// numbers (units), falling back to whatever the list record carried.
|
||||
const containerOptions = useMemo(() => {
|
||||
const real = (n?: string | null): n is string =>
|
||||
Boolean(n) && !/^TBD/i.test(n!.trim());
|
||||
const out: string[] = [];
|
||||
for (const c of assignBooking?.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.length ? out : activeRecord ? bookingContainerNumbers(activeRecord) : [];
|
||||
}, [assignBooking, activeRecord]);
|
||||
|
||||
const selectedIds = useMemo(
|
||||
() => Object.keys(rowSelection).filter((id) => rowSelection[id]),
|
||||
[rowSelection],
|
||||
@@ -1312,7 +1341,7 @@ const FirstMilePage = () => {
|
||||
style={{ flex: 1 }}
|
||||
label={i === 0 ? "Container no." : undefined}
|
||||
placeholder="Container number"
|
||||
data={(activeRecord ? bookingContainerNumbers(activeRecord) : []).filter(
|
||||
data={containerOptions.filter(
|
||||
(n) =>
|
||||
n === row.containerNumber ||
|
||||
!vehicleRows.some((r, idx) => idx !== i && r.containerNumber === n),
|
||||
|
||||
@@ -42,6 +42,7 @@ import {
|
||||
} from "@mantine/core";
|
||||
import type { ArrivalQueueItem, ImportUnloadedItem, WarehouseInventoryItem } from "@/types/warehouse";
|
||||
import { warehouseService } from "@/services/warehouse.service";
|
||||
import { bookingsService } from "@/services/bookings.service";
|
||||
|
||||
import { ruleEngineTable } from "@/components/ruleEngine/ruleEngineStyles";
|
||||
import { QUERY_KEYS } from "@/constants/QUERY_KEYS";
|
||||
@@ -853,6 +854,35 @@ const LastMilePage = () => {
|
||||
return opts;
|
||||
}, [vehicleOptions, activeRecord]);
|
||||
|
||||
// Full booking (with container units) for the assign modal's container dropdown.
|
||||
// Fetched on open so container numbers show regardless of what the list embeds.
|
||||
const { data: assignBooking } = useQuery({
|
||||
queryKey: activeRecord?.bookingId
|
||||
? QUERY_KEYS.BOOKINGS.byId(activeRecord.bookingId)
|
||||
: ["bookings", "detail", "none"],
|
||||
queryFn: () => bookingsService.getById(activeRecord!.bookingId),
|
||||
enabled: assignOpen && !bulkMode && Boolean(activeRecord?.bookingId),
|
||||
});
|
||||
|
||||
// Container-number options for the dropdown = the booking's real per-container
|
||||
// numbers (units), falling back to whatever the list record carried.
|
||||
const containerOptions = useMemo(() => {
|
||||
const real = (n?: string | null): n is string =>
|
||||
Boolean(n) && !/^TBD/i.test(n!.trim());
|
||||
const out: string[] = [];
|
||||
for (const c of assignBooking?.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.length ? out : activeRecord ? bookingContainerNumbers(activeRecord) : [];
|
||||
}, [assignBooking, activeRecord]);
|
||||
|
||||
const pickupReadyByBooking = useMemo(() => {
|
||||
const map = new Map<string, ImportUnloadedItem>();
|
||||
for (const row of pickupReadyRows) {
|
||||
@@ -1671,7 +1701,7 @@ const LastMilePage = () => {
|
||||
style={{ flex: 1 }}
|
||||
label={i === 0 ? "Container no." : undefined}
|
||||
placeholder="Container number"
|
||||
data={(activeRecord ? bookingContainerNumbers(activeRecord) : []).filter(
|
||||
data={containerOptions.filter(
|
||||
(n) =>
|
||||
n === row.containerNumber ||
|
||||
!vehicleRows.some((r, idx) => idx !== i && r.containerNumber === n),
|
||||
|
||||
@@ -83,6 +83,8 @@ export interface BookingContainerUnit {
|
||||
export interface BookingContainerLine {
|
||||
id: string;
|
||||
containerTypeId: string;
|
||||
/** Line-level number — often a "TBD-…" placeholder; real numbers live in units. */
|
||||
containerNumber?: string | null;
|
||||
quantity: number;
|
||||
vgmPerUnitTons: number;
|
||||
containerType?: {
|
||||
|
||||
Reference in New Issue
Block a user