updates on the reverse logistics

This commit is contained in:
2026-10-07 13:00:43 +05:30
parent 0d5edf94bf
commit ff1b795292
7 changed files with 354 additions and 32 deletions

View File

@@ -108,6 +108,9 @@ const BOOKING_KEYS = [
['doormile', 'bookings'],
['doormile', 'deliveries'],
['doormile', 'delivery-counts'],
// A parcel's timeline (ConsignmentTimeline), so a status change made from
// Deliveries shows in an open order drawer at once.
['doormile', 'returns', 'history'],
];
/* ── Dashboard, reports, profile ──────────────────────────────────────────── */
@@ -557,6 +560,25 @@ export const useReturns = (params = {}, options) =>
...options,
});
/* Both live under the returns key, so every return action above refreshes them. */
export const useReturnsSummary = (params = {}, options) =>
useQuery({
queryKey: ['doormile', 'returns', 'summary', params],
queryFn: () => api.getReturnsSummary(params),
placeholderData: (previous) => previous,
staleTime: 60_000,
...options,
});
export const useConsignmentHistory = (consignmentId, options) =>
useQuery({
queryKey: ['doormile', 'returns', 'history', String(consignmentId)],
queryFn: () => api.getConsignmentHistory(consignmentId),
enabled: !!consignmentId,
staleTime: 15_000,
...options,
});
export const useInitiateRto = () =>
useDoormileMutation({
mutationFn: ({ consignmentId, reason, note }) => api.initiateRto(consignmentId, { reason, note }),