change price logic on the ,rule engine ui, auto generate the contrat

This commit is contained in:
marshal
2026-06-08 10:04:23 +03:00
parent 4993453993
commit 88df20be6b
76 changed files with 4907 additions and 225 deletions

View File

@@ -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"),