buster/web/src/api/query_keys/dashboard.ts

28 lines
837 B
TypeScript

import { queryOptions } from '@tanstack/react-query';
import type {
BusterDashboardListItem,
BusterDashboardResponse
} from '@/api/asset_interfaces/dashboard';
import { dashboardsGetList } from '../buster_rest/dashboards';
const dashboardGetList = (
filters: Omit<Parameters<typeof dashboardsGetList>[0], 'page_token' | 'page_size'>
) =>
queryOptions<BusterDashboardListItem[]>({
queryKey: ['dashboard', 'list', filters] as const,
initialData: [],
staleTime: 60 * 1000,
initialDataUpdatedAt: 0
});
const dashboardGetDashboard = (dashboardId: string, version_number?: number) =>
queryOptions<BusterDashboardResponse>({
queryKey: ['dashboard', 'get', dashboardId, version_number] as const,
staleTime: 10 * 1000
});
export const dashboardQueryKeys = {
dashboardGetDashboard,
dashboardGetList
};