mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
Implement intercity document handling and rejection notes for contracts
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
import { MutationCache, QueryClient } from "@tanstack/react-query";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import {
|
||||
extractApiErrorPayload,
|
||||
isGlobalErrorModalSuppressed,
|
||||
} from "@/components/errors/ApiErrorModal";
|
||||
import type { InvalidatesMeta } from "@/utils/endpoint";
|
||||
|
||||
/**
|
||||
@@ -28,19 +23,9 @@ export const queryClient = new QueryClient({
|
||||
void queryClient.invalidateQueries({ queryKey });
|
||||
}
|
||||
},
|
||||
// Global mutation-failure surface: show the SERVER's actual message instead
|
||||
// of a page's hardcoded "Failed to …". On pages where the global error
|
||||
// modal shows (non-suppressed), it already carries the message, so a toast
|
||||
// here would double up — fire the toast only on modal-suppressed paths
|
||||
// (warehouse / first-last mile / onboarding). Opt a single mutation out with
|
||||
// meta.skipGlobalErrorToast when it handles the error inline (e.g. a modal).
|
||||
onError: (error, _variables, _context, mutation) => {
|
||||
if (mutation.meta?.skipGlobalErrorToast) return;
|
||||
if (!isGlobalErrorModalSuppressed(window.location.pathname)) return;
|
||||
const payload = extractApiErrorPayload(error);
|
||||
if (!payload?.messages.length) return;
|
||||
toast.error(payload.messages.join("\n"));
|
||||
},
|
||||
// Mutation failures are surfaced globally by the axios interceptor in
|
||||
// auth/http.ts (server-message toast on every non-401 failure), so no
|
||||
// onError toast here — it would double up.
|
||||
}),
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
|
||||
Reference in New Issue
Block a user