updates on the reverse logistics
This commit is contained in:
@@ -541,6 +541,43 @@ export const useCancelDelivery = () =>
|
||||
successMessage: 'Delivery cancelled',
|
||||
});
|
||||
|
||||
/* ── Reverse logistics (RTO) ──────────────────────────────────────────────── */
|
||||
|
||||
// Exceptions too: starting a return resolves the parcel's Undeliverable /
|
||||
// Receiver_Refused exception on the server, and the list must show that at
|
||||
// once rather than on its next poll.
|
||||
const RETURN_KEYS = [...BOOKING_KEYS, ['doormile', 'returns'], KEYS.exceptions];
|
||||
|
||||
export const useReturns = (params = {}, options) =>
|
||||
useQuery({
|
||||
queryKey: ['doormile', 'returns', params],
|
||||
queryFn: () => api.getReturns(params),
|
||||
placeholderData: (previous) => previous,
|
||||
staleTime: 15_000,
|
||||
...options,
|
||||
});
|
||||
|
||||
export const useInitiateRto = () =>
|
||||
useDoormileMutation({
|
||||
mutationFn: ({ consignmentId, reason, note }) => api.initiateRto(consignmentId, { reason, note }),
|
||||
invalidates: RETURN_KEYS,
|
||||
successMessage: 'Return to sender started',
|
||||
});
|
||||
|
||||
export const useCancelRto = () =>
|
||||
useDoormileMutation({
|
||||
mutationFn: ({ consignmentId, note }) => api.cancelRto(consignmentId, note),
|
||||
invalidates: RETURN_KEYS,
|
||||
successMessage: 'Return cancelled — delivery will be re-attempted',
|
||||
});
|
||||
|
||||
export const useCompleteRto = () =>
|
||||
useDoormileMutation({
|
||||
mutationFn: ({ consignmentId, note }) => api.completeRto(consignmentId, note),
|
||||
invalidates: RETURN_KEYS,
|
||||
successMessage: 'Marked returned to sender',
|
||||
});
|
||||
|
||||
/* ── Consignments ─────────────────────────────────────────────────────────── */
|
||||
|
||||
export const useConsignments = (options) =>
|
||||
|
||||
Reference in New Issue
Block a user