mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
change price logic on the ,rule engine ui, auto generate the contrat
This commit is contained in:
@@ -26,6 +26,52 @@ export const useRuleEngineList = (
|
||||
queryFn: () => ruleEngineService.list(resource, params),
|
||||
});
|
||||
|
||||
const ORDER_LIST_PAGE_SIZE = 500;
|
||||
|
||||
export const useRuleEngineOrderList = (
|
||||
resource: RuleEngineResourceSlug,
|
||||
enabled: boolean,
|
||||
sortBy?: string,
|
||||
) =>
|
||||
useQuery({
|
||||
queryKey: QUERY_KEYS.RULE_ENGINE.orderList(resource),
|
||||
queryFn: () =>
|
||||
ruleEngineService.list(resource, {
|
||||
page: 1,
|
||||
pageSize: ORDER_LIST_PAGE_SIZE,
|
||||
sortBy,
|
||||
sortOrder: "ASC",
|
||||
}),
|
||||
enabled,
|
||||
});
|
||||
|
||||
export const useRuleEngineOrderMutations = (resource: RuleEngineResourceSlug) => {
|
||||
const qc = useQueryClient();
|
||||
|
||||
const reorder = useMutation({
|
||||
mutationFn: (payload: { ids: string[]; requiresDirectorApproval?: boolean }) =>
|
||||
ruleEngineService.reorder(resource, payload),
|
||||
onSuccess: async () => {
|
||||
toast.success("Order updated");
|
||||
await invalidateRuleEngineList(qc, resource);
|
||||
await qc.invalidateQueries({ queryKey: QUERY_KEYS.RULE_ENGINE.orderList(resource) });
|
||||
},
|
||||
onError: () => toast.error("Failed to update order"),
|
||||
});
|
||||
|
||||
const moveOrder = useMutation({
|
||||
mutationFn: ({ id, direction }: { id: string; direction: "up" | "down" }) =>
|
||||
ruleEngineService.moveOrder(resource, id, direction),
|
||||
onSuccess: async () => {
|
||||
await invalidateRuleEngineList(qc, resource);
|
||||
await qc.invalidateQueries({ queryKey: QUERY_KEYS.RULE_ENGINE.orderList(resource) });
|
||||
},
|
||||
onError: () => toast.error("Cannot move item further in that direction"),
|
||||
});
|
||||
|
||||
return { reorder, moveOrder };
|
||||
};
|
||||
|
||||
export const useCargoTypeParentOptions = (excludeId?: string, enabled = true) =>
|
||||
useQuery({
|
||||
queryKey: QUERY_KEYS.RULE_ENGINE.selectOptions("cargo-types"),
|
||||
|
||||
Reference in New Issue
Block a user