updates on the delviereis page
This commit is contained in:
@@ -83,6 +83,8 @@ const BOOKING_STATUS_TO_DELIVERY_STATUS = {
|
||||
pending_assignment: 'pending',
|
||||
pending: 'pending',
|
||||
miler_assigned: 'pending',
|
||||
assigned: 'pending',
|
||||
rider_assigned: 'pending',
|
||||
pickup_scheduled: 'accepted',
|
||||
arrived: 'arrived',
|
||||
converted_to_consignment: 'picked',
|
||||
@@ -797,9 +799,17 @@ export const fetchDeliveries = async ({ pageParam = 1, queryKey }) => {
|
||||
|
||||
const isDispatched = (b) => {
|
||||
if (!b) return false;
|
||||
const riderId = b.assignedmileruserid ?? b.assigned_miler_user_id ?? b.mileruserid ?? b.milerid ?? b.assignedmilerid;
|
||||
const riderId =
|
||||
b.assignedmileruserid ??
|
||||
b.assigned_miler_user_id ??
|
||||
b.mileruserid ??
|
||||
b.milerid ??
|
||||
b.assignedmilerid ??
|
||||
b.milerprofileid ??
|
||||
b.riderid ??
|
||||
b.rider_id;
|
||||
const consignmentId = b.consignmentid ?? b.consignment_id;
|
||||
const rawStatus = String(b.status || b.orderstatus || '').trim().toLowerCase();
|
||||
const rawStatus = String(b.status || b.orderstatus || b.bookingstatus || '').trim().toLowerCase();
|
||||
if (riderId || consignmentId) return true;
|
||||
if (rawStatus && !['pending_pickup', 'created', 'new', 'booked', 'order_placed', 'unassigned', ''].includes(rawStatus)) {
|
||||
return true;
|
||||
@@ -819,6 +829,9 @@ export const fetchDeliveries = async ({ pageParam = 1, queryKey }) => {
|
||||
b.mileruserid ??
|
||||
b.milerid ??
|
||||
b.assignedmilerid ??
|
||||
b.milerprofileid ??
|
||||
b.riderid ??
|
||||
b.rider_id ??
|
||||
consignment?.assignedmileruserid ??
|
||||
consignment?.mileruserid ??
|
||||
consignment?.milerid;
|
||||
@@ -841,6 +854,8 @@ export const fetchDeliveries = async ({ pageParam = 1, queryKey }) => {
|
||||
b.milername ||
|
||||
b.ridername ||
|
||||
b.assignedmilername ||
|
||||
b.miler_name ||
|
||||
b.rider_name ||
|
||||
consignment?.milername ||
|
||||
consignment?.ridername ||
|
||||
consignment?.assignedmilername ||
|
||||
@@ -853,10 +868,14 @@ export const fetchDeliveries = async ({ pageParam = 1, queryKey }) => {
|
||||
bookingno: b.bookingno,
|
||||
orderid: b.bookingno || (b.bookingid ? `#${b.bookingid}` : (b.id ? `#${b.id}` : '')),
|
||||
consignmentid: consignmentId,
|
||||
hubid: b.hubid,
|
||||
sourcehubid: b.sourcehubid,
|
||||
tenantid: b.tenantid,
|
||||
tenantname: tenant?.tenantname || '',
|
||||
tenantsuburb: '',
|
||||
applocation: '',
|
||||
applocationid: b.applocationid,
|
||||
tenantlocationid: b.tenantlocationid,
|
||||
tenantadress: tenant?.primaryemail || '',
|
||||
locationname: tenant?.tenantname || '',
|
||||
locationsuburb: '',
|
||||
@@ -898,10 +917,10 @@ export const fetchDeliveries = async ({ pageParam = 1, queryKey }) => {
|
||||
collectionamt: undefined,
|
||||
notes: b.notes || '',
|
||||
deliverytype: customer ? 'B' : 'C',
|
||||
orderdate: b.createdat,
|
||||
orderdate: b.createdat || b.orderdate || b.updatedat,
|
||||
deliverydate: b.serviceoptions?.[0]?.estimateddeliveryat || b.updatedat,
|
||||
reachedat: reached,
|
||||
assigntime: b.updatedat,
|
||||
assigntime: b.updatedat || b.createdat,
|
||||
// The consignment's status WINS when there is one (e.g. Collected_By_Miler -> Picked,
|
||||
// Out_for_Delivery -> Active, Delivered -> Delivered).
|
||||
// If status == Converted_To_Consignment, switches to consignmentstatus.
|
||||
@@ -961,9 +980,17 @@ const getDeliveryStatusCounts = async () => {
|
||||
});
|
||||
const isDispatched = (b) => {
|
||||
if (!b) return false;
|
||||
const riderId = b.assignedmileruserid ?? b.assigned_miler_user_id ?? b.mileruserid ?? b.milerid ?? b.assignedmilerid;
|
||||
const riderId =
|
||||
b.assignedmileruserid ??
|
||||
b.assigned_miler_user_id ??
|
||||
b.mileruserid ??
|
||||
b.milerid ??
|
||||
b.assignedmilerid ??
|
||||
b.milerprofileid ??
|
||||
b.riderid ??
|
||||
b.rider_id;
|
||||
const consignmentId = b.consignmentid ?? b.consignment_id;
|
||||
const rawStatus = String(b.status || b.orderstatus || '').trim().toLowerCase();
|
||||
const rawStatus = String(b.status || b.orderstatus || b.bookingstatus || '').trim().toLowerCase();
|
||||
if (riderId || consignmentId) return true;
|
||||
if (rawStatus && !['pending_pickup', 'created', 'new', 'booked', 'order_placed', 'unassigned', ''].includes(rawStatus)) {
|
||||
return true;
|
||||
|
||||
@@ -108,11 +108,25 @@ export function ZoneProvider({ children }) {
|
||||
const currentHub = selectedZone;
|
||||
const targetHubId = String(currentHub.hubid);
|
||||
|
||||
const isOrderOrDeliveryOrTripsheet = Boolean(
|
||||
item.bookingid != null ||
|
||||
item.orderheaderid != null ||
|
||||
item.deliveryid != null ||
|
||||
item.bookingno != null ||
|
||||
item.consignmentid != null ||
|
||||
item.tripsheetid != null ||
|
||||
item.pickupaddress != null ||
|
||||
item.deliveryaddress != null
|
||||
);
|
||||
|
||||
// Rider matching: riders belong to the tenant fleet and serve all tenant kitchen hubs
|
||||
const isRiderItem =
|
||||
item.milerprofileid != null ||
|
||||
item.authname != null ||
|
||||
(item.userid != null && item.availabilitystatus != null);
|
||||
!isOrderOrDeliveryOrTripsheet &&
|
||||
Boolean(
|
||||
item.milerprofileid != null ||
|
||||
item.authname != null ||
|
||||
(item.userid != null && item.availabilitystatus != null)
|
||||
);
|
||||
|
||||
if (isRiderItem) {
|
||||
if (isTenantUser) {
|
||||
|
||||
Reference in New Issue
Block a user