Truck assign containers

This commit is contained in:
Hagernesh
2026-07-04 07:56:23 +00:00
parent e8e3e01f31
commit 8916182a62
3 changed files with 41 additions and 7 deletions

View File

@@ -1086,6 +1086,9 @@ export class BookingTransitionService {
offeredAmount: number;
paymentDeadline: Date;
} | null;
/** Flat list of physical container numbers on this booking (for the
* customer truck-assignment container picker). */
containerNumbers: string[];
}
> {
// This enrichment runs AFTER the transition has committed. A failure here
@@ -1141,12 +1144,20 @@ export class BookingTransitionService {
`enrichBookingResponse: batch-offer lookup failed for ${booking.id}: ${(err as Error).message}`,
);
}
// Physical container numbers entered at booking time (booking_container
// units), flattened for the customer truck-assignment container picker.
const containerNumbers = (booking.bookingContainers ?? [])
.flatMap((bc) => bc.units ?? [])
.map((unit) => unit.containerNumber)
.filter((n): n is string => Boolean(n));
return {
...booking,
latestChangeRequestNote: note?.note ?? null,
contractSummary: summary,
nextStep,
activeBatchOffer,
containerNumbers,
};
}
}

View File

@@ -38,6 +38,11 @@ export function CustomerTruckAssignmentCard({
);
const [error, setError] = useState<string | null>(null);
// Physical container numbers on this booking — the customer picks which one to
// load onto the truck instead of typing it. Falls back to free entry when the
// booking has no container numbers recorded.
const containerOptions = booking.containerNumbers ?? [];
const assignMutation = useMutation(api.bookings.assignCustomerTruck.mutationOptions());
const downloadMutation = useMutation(api.bookings.downloadCustomerTruckFreightOrder.mutationOptions());
@@ -120,13 +125,27 @@ export function CustomerTruckAssignmentCard({
onChange={(value) => setTruckType(value ?? "")}
disabled={assigned}
/>
<TextInput
label="Container Number to Load"
required
value={containerNumberToLoad}
onChange={(e) => setContainerNumberToLoad(e.currentTarget.value.toUpperCase())}
readOnly={assigned}
/>
{containerOptions.length > 0 ? (
<Select
label="Container Number to Load"
required
placeholder="Select a container from this booking"
data={containerOptions}
value={containerNumberToLoad || null}
onChange={(value) => setContainerNumberToLoad(value ?? "")}
searchable
disabled={assigned}
nothingFoundMessage="No matching container"
/>
) : (
<TextInput
label="Container Number to Load"
required
value={containerNumberToLoad}
onChange={(e) => setContainerNumberToLoad(e.currentTarget.value.toUpperCase())}
readOnly={assigned}
/>
)}
</SimpleGrid>
<Group justify="flex-end">

View File

@@ -466,6 +466,10 @@ export interface IBooking extends BaseEntity {
containers?: Array<{ type: string; qty: number; vgm: number }> | null;
/** Physical container numbers on this booking (from booking container units),
* surfaced for the customer truck-assignment container picker. */
containerNumbers?: string[] | null;
versionNumber: number;
priorityScore: number;