mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 12:18:11 +00:00
add yard distances management to rule engine
- Introduced new yard distances resource with CRUD operations. - Created migration for yard distances table with necessary constraints. - Implemented service and repository for yard distances handling. - Added controller for API endpoints to manage yard distances. - Updated rule engine configuration to include yard distances. - Enhanced rule engine resource page to support yard distance selection. - Updated contracts and train builder pages to handle new yard distance logic. - Added error handling utility for better error message extraction.
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
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";
|
||||
|
||||
/**
|
||||
@@ -23,6 +28,19 @@ 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"));
|
||||
},
|
||||
}),
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
|
||||
Reference in New Issue
Block a user