updates on the changes arelated toe the order creation and delivery fixes as well
This commit is contained in:
@@ -432,7 +432,10 @@ const Deliveries = () => {
|
||||
} = useQuery({
|
||||
queryKey: ['tenantlist', appId],
|
||||
queryFn: () => getTenants(appId), // Ensure appId is passed
|
||||
enabled: appId !== 0 // Ensures query runs only when appId is valid
|
||||
// appId 0 is a real, deliberate choice — the synthetic "All" zone option
|
||||
// (fetchAppLocations in api.js) — not "nothing picked yet"; only
|
||||
// null/undefined means that now. See LocationAutocomplete.js's onChange.
|
||||
enabled: appId != null
|
||||
});
|
||||
// ==============================|| gettenantlocations ||============================== //
|
||||
|
||||
@@ -799,7 +802,7 @@ const Deliveries = () => {
|
||||
// throwing after already toasting there too, which showed this same
|
||||
// error twice) — no onError needed here anymore.
|
||||
queryFn: fetchRidersList,
|
||||
enabled: Boolean(appId)
|
||||
enabled: appId != null
|
||||
});
|
||||
|
||||
/* ============================================= || updatedelivery | ============================================= */
|
||||
@@ -814,10 +817,16 @@ const Deliveries = () => {
|
||||
setDialogopen(false);
|
||||
fetchCountRefetch();
|
||||
countSourceRefetch();
|
||||
} else {
|
||||
// A 200 with success:false (the Doormile API's validation-failure
|
||||
// shape, same pattern as customers.js's saveMutation) had no else
|
||||
// branch here before — the dialog just sat open with zero feedback,
|
||||
// looking exactly like the button didn't work.
|
||||
opentoast(res.message || 'Failed to update delivery', 'error');
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
opentoast(err.message, 'success');
|
||||
opentoast(err.response?.data?.message || err.message || 'Failed to update delivery', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1127,7 +1136,7 @@ const Deliveries = () => {
|
||||
PaperComponent={SoftPaper}
|
||||
sx={{ flex: { xs: '1 1 100%', sm: '1 1 180px' }, minWidth: { xs: '100%', sm: 180 } }}
|
||||
onOpen={(event) => {
|
||||
if (!appId) {
|
||||
if (appId == null) {
|
||||
event.preventDefault();
|
||||
OpenToast('Please select your zone first!', 'warning', 3000);
|
||||
setTimeout(() => locationRef.current?.focus(), 0);
|
||||
@@ -1174,7 +1183,7 @@ const Deliveries = () => {
|
||||
PaperComponent={SoftPaper}
|
||||
sx={{ flex: { xs: '1 1 100%', sm: '1 1 180px' }, minWidth: { xs: '100%', sm: 180 } }}
|
||||
onOpen={(event) => {
|
||||
if (!appId && !tenantid) {
|
||||
if (appId == null && !tenantid) {
|
||||
event.preventDefault();
|
||||
OpenToast('Please select your Zone and Tenant first!', 'warning', 3000);
|
||||
setTimeout(() => locationRef.current?.focus(), 0);
|
||||
@@ -1226,7 +1235,7 @@ const Deliveries = () => {
|
||||
else setRiderid(value.userid);
|
||||
}}
|
||||
onOpen={(event) => {
|
||||
if (!appId) {
|
||||
if (appId == null) {
|
||||
event.preventDefault();
|
||||
OpenToast('Please select your zone first!', 'warning', 3000);
|
||||
setTimeout(() => locationRef.current?.focus(), 0);
|
||||
@@ -1614,7 +1623,7 @@ const Deliveries = () => {
|
||||
</MobileField>
|
||||
<MobileField
|
||||
label="ETA"
|
||||
value={row.expecteddeliverytime ? dayjs(row.expecteddeliverytime).format('hh:mm A') : '—'}
|
||||
value={row.expecteddeliverytime ? parseDoormileTimestamp(row.expecteddeliverytime).format('hh:mm A') : '—'}
|
||||
/>
|
||||
<MobileField label="Transit">
|
||||
<Box sx={chipSx('#06b6d4')}>{row.transitminutes || 0}m</Box>
|
||||
@@ -1920,17 +1929,19 @@ const Deliveries = () => {
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
{/* express-console-api.md: Doormile timestamps are IST
|
||||
wall-clock with no timezone marker — .utc() was
|
||||
reinterpreting that naive string as local time and
|
||||
shifting it back 5:30, showing the wrong time (and
|
||||
sometimes the wrong day). Parse bare, matching the
|
||||
already-correct convention in getRowBatchId above. */}
|
||||
wall-clock with no timezone marker — bare dayjs() was
|
||||
still being used here despite this comment saying
|
||||
otherwise (the fix was never actually applied below,
|
||||
only claimed) — a Z-suffixed response reinterprets as
|
||||
local time and shifts 5:30, showing the wrong time
|
||||
(and sometimes the wrong day). parseDoormileTimestamp
|
||||
strips that, matching getRowBatchId above. */}
|
||||
<Tooltip title="Ordered date" placement="top">
|
||||
<Typography noWrap sx={{ fontSize: '12px' }}>
|
||||
{dayjs(row.orderdate).format('DD/MM/YYYY')}
|
||||
{parseDoormileTimestamp(row.orderdate).format('DD/MM/YYYY')}
|
||||
</Typography>
|
||||
<Typography noWrap sx={{ fontSize: '11px' }}>
|
||||
{dayjs(row.orderdate).format('hh:mm A')}
|
||||
{parseDoormileTimestamp(row.orderdate).format('hh:mm A')}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</Stack>
|
||||
@@ -1943,11 +1954,11 @@ const Deliveries = () => {
|
||||
</Tooltip>
|
||||
<Tooltip title="Delivery date" placement="top">
|
||||
<Typography noWrap sx={{ fontSize: '12px' }}>
|
||||
{dayjs(row.deliverydate).format('DD/MM/YYYY')}
|
||||
{parseDoormileTimestamp(row.deliverydate).format('DD/MM/YYYY')}
|
||||
</Typography>
|
||||
|
||||
<Typography noWrap sx={{ fontSize: '11px' }}>
|
||||
{dayjs(row.deliverydate).format('hh:mm A')}
|
||||
{parseDoormileTimestamp(row.deliverydate).format('hh:mm A')}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</Stack>
|
||||
@@ -2028,7 +2039,7 @@ const Deliveries = () => {
|
||||
{/* Estimated Delivery Time */}
|
||||
<TableCell align="left">
|
||||
<Typography variant="subtitle2" sx={{ fontWeight: 700, color: DT.textPrimary, whiteSpace: 'nowrap' }}>
|
||||
{row.expecteddeliverytime ? dayjs(row.expecteddeliverytime).format('hh:mm A') : '—'}
|
||||
{row.expecteddeliverytime ? parseDoormileTimestamp(row.expecteddeliverytime).format('hh:mm A') : '—'}
|
||||
</Typography>
|
||||
</TableCell>
|
||||
{/* Transit Minutes */}
|
||||
@@ -2455,7 +2466,7 @@ const Deliveries = () => {
|
||||
{['pending', 'accepted', 'arrived'].includes(selectedRow?.orderstatus) && (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
if (!appId) {
|
||||
if (appId == null) {
|
||||
opentoast('Please select a location first!', 'warning');
|
||||
locationRef.current?.focus();
|
||||
return;
|
||||
@@ -2476,6 +2487,22 @@ const Deliveries = () => {
|
||||
already could. */}
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
// PUT /admin/consignments/:id/status is consignment-scoped — it
|
||||
// only exists once the rider marks pickup-complete (doormile-flow.md).
|
||||
// Without a real consignmentid, updateDeliveryAPI's `?? deliveryid`
|
||||
// fallback was sending the BOOKING id where a consignment id is
|
||||
// required — a different id space, so the call failed against
|
||||
// the wrong (or nonexistent) resource. Combined with the mutation's
|
||||
// onSuccess only handling `res.success === true` with no else
|
||||
// branch, that failure was completely silent — dialog just sat
|
||||
// there looking like nothing happened. Block it here instead,
|
||||
// with a message that explains why, rather than letting the
|
||||
// submit silently no-op.
|
||||
if (!selectedRow.consignmentid) {
|
||||
opentoast("This order hasn't been picked up yet — status can only be updated once it becomes a consignment.", 'warning');
|
||||
handleMenuClose();
|
||||
return;
|
||||
}
|
||||
setKms(selectedRow.kms);
|
||||
setCumulativeKms(selectedRow.cumulativekms);
|
||||
setDeliverylat(selectedRow.droplat);
|
||||
|
||||
Reference in New Issue
Block a user