rez-table-listing-mui
Version:
A rez table listing component built on TanStack Table
54 lines (50 loc) • 1.38 kB
text/typescript
import { useQueries, useQuery } from "@tanstack/react-query";
import { getKanbanData } from "../services/service";
import {
commonFetchDropdownDataAPI,
newCommonGetDropdownDataAPI,
} from "../../listing/libs/utils/apiColumn";
export const kanbanDropdownResults = (
entity_type: string,
enterprise_id: number
) => {
return useQueries({
queries: [
{
queryKey: ["commonDropdown", entity_type, enterprise_id],
queryFn: () =>
commonFetchDropdownDataAPI({
entity_type,
enterprise_id,
}),
enabled: !!enterprise_id,
},
],
});
};
export const useGetAttributeDropdown = (
entity_type: string,
attribute_key: string
) =>
useQuery({
queryKey: ["commonDropdown", entity_type, attribute_key],
queryFn: () =>
newCommonGetDropdownDataAPI({
entity_type,
attribute_key,
}),
enabled: Boolean(entity_type && attribute_key),
});
export const useGetKanbanData = (entity_type: string) => {
const {
data: metaData,
isPending,
isLoading,
error,
} = useQuery({
queryKey: ["getKanbanData", entity_type],
queryFn: () => getKanbanData(entity_type),
enabled: !!entity_type, // Only fetch when workflowId is valid
});
return { metaData, isPending, isLoading, error };
};