diff --git a/src/api/doormile/queries.js b/src/api/doormile/queries.js index 614c549..497142d 100644 --- a/src/api/doormile/queries.js +++ b/src/api/doormile/queries.js @@ -142,6 +142,13 @@ export const deriveDeliveryStatus = (bookingOrStatus, consignmentMapOrReachedAt) // - 'cancelled' -> 'cancelled' (Cancelled tab) if (cStatus) { const rawC = String(cStatus).trim().toLowerCase(); + // A booking sitting at converted_to_consignment / collected_by_miler is in the 'picked' + // state (parcel in rider's hand after pickup). Generic DB record status 'active' on the + // consignment must not preemptively bump it to 'active' (Out for Delivery) until the + // consignment is explicitly marked 'out_for_delivery' / 'in_transit' / etc. + if (rawC === 'active' && (rawBookingStatus === 'converted_to_consignment' || rawBookingStatus === 'collected_by_miler' || rawBookingStatus === 'picked')) { + return 'picked'; + } const mappedC = BOOKING_STATUS_TO_DELIVERY_STATUS[rawC]; if (mappedC) return mappedC; } @@ -179,7 +186,9 @@ const consignmentStatusFor = (booking, consignmentMap) => { if (!consignmentId || !consignmentMap?.size) return undefined; const record = consignmentMap.get(String(consignmentId)); if (!record) return undefined; - const raw = record.status ?? record.consignmentstatus ?? record.currentstatus ?? record.consignment_status; + // Specific consignment lifecycle fields (consignmentstatus / consignment_status / currentstatus) + // MUST take precedence over the generic DB entity status column (record.status). + const raw = record.consignmentstatus ?? record.consignment_status ?? record.currentstatus ?? record.status; return typeof raw === 'string' && raw.trim() ? raw.trim() : undefined; }; diff --git a/src/layouts/AdminLayout.jsx b/src/layouts/AdminLayout.jsx index 401d789..aacf29d 100644 --- a/src/layouts/AdminLayout.jsx +++ b/src/layouts/AdminLayout.jsx @@ -222,10 +222,28 @@ function NotificationsMenu() { export default function AdminLayout() { const location = useLocation(); const navigate = useNavigate(); - const { user, logout } = useAuth(); + const { user, isClient, logout } = useAuth(); const [menuOpen, setMenuOpen] = useState(false); const [assistantOpen, setAssistantOpen] = useState(false); + const navItems = useMemo(() => { + if (isClient) { + return NAV.filter((item) => item.path !== '/doormile/tenants'); + } + return NAV; + }, [isClient]); + + const navGroups = useMemo(() => { + if (isClient) { + return NAV_GROUPS.filter((group) => group.label !== 'Fleet Ops'); + } + return NAV_GROUPS; + }, [isClient]); + + const allDestinations = useMemo(() => { + return [...navItems, ...navGroups.flatMap((group) => group.items)]; + }, [navItems, navGroups]); + const isActive = (path) => { if (path === ROOT) return location.pathname === ROOT; return location.pathname === path || location.pathname.startsWith(`${path}/`); @@ -269,7 +287,7 @@ export default function AdminLayout() { menu is styled as one more tab, so a destination reached through a menu still reads as being in the same row as the rest. */}