This commit is contained in:
ghost2023
2026-06-03 15:31:29 +03:00
parent 9e4e44ee6a
commit c2145b48f5

View File

@@ -9,6 +9,7 @@ import type {
RuleEngineRecord,
RuleEngineResourceSlug,
} from "@/types/rule-engine";
import { QUERY_KEYS } from "@/constants/TANSTACK_QUEY_KEY";
const CARGO_TYPE_PARENT_PAGE_SIZE = 500;
const CONTAINER_TYPE_OPTIONS_PAGE_SIZE = 500;
@@ -46,9 +47,7 @@ export const useCargoTypeParentOptions = (excludeId?: string, enabled = true) =>
const name = String(row.cargoTypeName ?? "").trim();
const code = String(row.code ?? "").trim();
const label =
name && code
? `${name} (${code})`
: name || code || String(row.id);
name && code ? `${name} (${code})` : name || code || String(row.id);
return { label, value: String(row.id) };
});
return [noneOption, ...parents];
@@ -62,9 +61,12 @@ export const useContainerTypeOptions = (enabled = true) =>
"select-options",
],
queryFn: () =>
ruleEngineService.list<RuleEngineRecord>("container-types", {
page: 1,
pageSize: CONTAINER_TYPE_OPTIONS_PAGE_SIZE,
api.ruleEngine.list.call({
resource: "container-types",
params: {
page: 1,
pageSize: CONTAINER_TYPE_OPTIONS_PAGE_SIZE,
},
}),
enabled,
select: (result) => {
@@ -123,8 +125,7 @@ export const useRuleEngineMutations = (resource: RuleEngineResourceSlug) => {
});
const remove = useMutation({
mutationFn: (id: string) =>
api.ruleEngine.remove.call({ resource, id }),
mutationFn: (id: string) => api.ruleEngine.remove.call({ resource, id }),
onSuccess: () => {
toast.success("Deleted successfully");
invalidate();
@@ -137,8 +138,7 @@ export const useRuleEngineMutations = (resource: RuleEngineResourceSlug) => {
export const useRateWorkflow = () => {
const qc = useQueryClient();
const invalidate = () =>
qc.invalidateQueries({ queryKey: listKey("rates") });
const invalidate = () => qc.invalidateQueries({ queryKey: listKey("rates") });
const submit = useMutation({
mutationFn: (id: string) => api.ruleEngine.submitRate.call({ id }),