mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +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:
@@ -21,6 +21,7 @@ import {
|
||||
invalidateRuleEngineList,
|
||||
patchRuleEngineListRecord,
|
||||
} from "@/utils/queryInvalidation";
|
||||
import { extractErrorMessage } from "@/utils/errorExtractor";
|
||||
|
||||
export const useRuleEngineList = (
|
||||
resource: RuleEngineResourceSlug,
|
||||
@@ -58,7 +59,7 @@ export const useRuleEngineOrderMutations = (resource: RuleEngineResourceSlug) =>
|
||||
await invalidateRuleEngineList(qc, resource);
|
||||
await qc.invalidateQueries({ queryKey: QUERY_KEYS.RULE_ENGINE.orderList(resource) });
|
||||
},
|
||||
onError: () => toast.error("Failed to update order"),
|
||||
onError: (err) => toast.error(extractErrorMessage(err, "Failed to update order")),
|
||||
});
|
||||
|
||||
const moveOrder = useMutation({
|
||||
@@ -273,7 +274,8 @@ export const useRuleEngineMutations = (resource: RuleEngineResourceSlug) => {
|
||||
patchRuleEngineListRecord(qc, resource, created);
|
||||
await invalidateRuleEngineList(qc, resource);
|
||||
},
|
||||
onError: () => toast.error("Failed to create record"),
|
||||
onError: (err) =>
|
||||
toast.error(extractErrorMessage(err, "Failed to create record")),
|
||||
});
|
||||
|
||||
const update = useMutation({
|
||||
@@ -289,7 +291,8 @@ export const useRuleEngineMutations = (resource: RuleEngineResourceSlug) => {
|
||||
patchRuleEngineListRecord(qc, resource, updated);
|
||||
await invalidateRuleEngineList(qc, resource);
|
||||
},
|
||||
onError: () => toast.error("Failed to update record"),
|
||||
onError: (err) =>
|
||||
toast.error(extractErrorMessage(err, "Failed to update record")),
|
||||
});
|
||||
|
||||
const remove = useMutation({
|
||||
@@ -299,7 +302,8 @@ export const useRuleEngineMutations = (resource: RuleEngineResourceSlug) => {
|
||||
toast.success("Deleted successfully");
|
||||
await invalidateRuleEngineList(qc, resource);
|
||||
},
|
||||
onError: () => toast.error("Failed to delete record"),
|
||||
onError: (err) =>
|
||||
toast.error(extractErrorMessage(err, "Failed to delete record")),
|
||||
});
|
||||
|
||||
return { create, update, remove };
|
||||
@@ -455,7 +459,7 @@ export const useRateWorkflow = () => {
|
||||
patchRuleEngineListRecord(qc, "rates", updated);
|
||||
await invalidateRuleEngineList(qc, "rates");
|
||||
},
|
||||
onError: () => toast.error("Failed to submit rate"),
|
||||
onError: (err) => toast.error(extractErrorMessage(err, "Failed to submit rate")),
|
||||
});
|
||||
|
||||
const approve = useMutation({
|
||||
@@ -465,7 +469,7 @@ export const useRateWorkflow = () => {
|
||||
patchRuleEngineListRecord(qc, "rates", updated);
|
||||
await invalidateRuleEngineList(qc, "rates");
|
||||
},
|
||||
onError: () => toast.error("Failed to approve rate"),
|
||||
onError: (err) => toast.error(extractErrorMessage(err, "Failed to approve rate")),
|
||||
});
|
||||
|
||||
return { submit, approve };
|
||||
|
||||
Reference in New Issue
Block a user