mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 07:22:53 +00:00
fix
This commit is contained in:
@@ -1003,6 +1003,13 @@ const LastMilePage = () => {
|
||||
const releaseRow =
|
||||
pickupReadyByBooking.get(row.original.bookingId) ?? pickupReadyByBooking.get(bookingRef(row.original));
|
||||
const truckArrivalLabel = releaseRow?.releaseOrderReference ? "Truck Leaving" : "Truck Arrival";
|
||||
// Only the current step's action is active; the rest stay disabled.
|
||||
// Step order: 0 Ready·1 Assign·2 Arrived·3 Leave·4 In-transit·5 Distance·6 Delivered.
|
||||
const activeStep = computeLastMileSteps(row.original, releaseRow).findIndex((s) => s.active);
|
||||
const canAdvance = activeStep === 0 || activeStep === 4 || activeStep === 6;
|
||||
const canAssignStep = activeStep === 1;
|
||||
const canTruck = activeStep === 2 || activeStep === 3;
|
||||
const canDistance = activeStep === 5;
|
||||
return (
|
||||
<Group gap={4} justify="flex-end" wrap="nowrap">
|
||||
<Menu position="bottom-end" width={200} withinPortal>
|
||||
@@ -1014,19 +1021,17 @@ const LastMilePage = () => {
|
||||
<Menu.Dropdown>
|
||||
<Menu.Item
|
||||
leftSection={<ArrowRight size={15} />}
|
||||
disabled={!nextStatus || (nextStatus === "IN_TRANSIT" && !assigned)}
|
||||
disabled={!nextStatus || !canAdvance}
|
||||
onClick={() => handleAdvanceStatus(row.original)}
|
||||
>
|
||||
{nextStatus === "IN_TRANSIT" && !assigned
|
||||
? "Assign a vehicle first"
|
||||
: nextStatus
|
||||
? `Mark ${STATUS_META[nextStatus].label}`
|
||||
: STATUS_META[row.original.status].label}
|
||||
{nextStatus
|
||||
? `Mark ${STATUS_META[nextStatus].label}`
|
||||
: STATUS_META[row.original.status].label}
|
||||
</Menu.Item>
|
||||
<Menu.Divider />
|
||||
<Menu.Item
|
||||
leftSection={<Truck size={15} />}
|
||||
disabled={assigned || delivered}
|
||||
disabled={!canAssignStep}
|
||||
onClick={() => openAssign(row.original.id)}
|
||||
>
|
||||
Assign
|
||||
@@ -1040,7 +1045,7 @@ const LastMilePage = () => {
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
leftSection={<Truck size={15} />}
|
||||
disabled={!assigned}
|
||||
disabled={!canTruck}
|
||||
onClick={() => openTruckArrival(row.original)}
|
||||
>
|
||||
{truckArrivalLabel}
|
||||
@@ -1054,7 +1059,7 @@ const LastMilePage = () => {
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
leftSection={<Ruler size={15} />}
|
||||
disabled={delivered}
|
||||
disabled={!canDistance}
|
||||
onClick={() => openDistance(row.original.id)}
|
||||
>
|
||||
Add distance
|
||||
|
||||
Reference in New Issue
Block a user