2025-02-14 05:28:45 +08:00
|
|
|
import { queryOptions } from '@tanstack/react-query';
|
2025-02-18 04:20:34 +08:00
|
|
|
import type {
|
|
|
|
BusterDashboardListItem,
|
|
|
|
BusterDashboardResponse
|
2025-03-08 07:02:56 +08:00
|
|
|
} from '@/api/asset_interfaces/dashboard';
|
2025-03-26 00:59:36 +08:00
|
|
|
import { dashboardsGetList } from '../buster_rest/dashboards';
|
2025-02-14 05:28:45 +08:00
|
|
|
|
2025-03-26 00:59:36 +08:00
|
|
|
const dashboardGetList = (
|
|
|
|
filters: Omit<Parameters<typeof dashboardsGetList>[0], 'page_token' | 'page_size'>
|
|
|
|
) =>
|
2025-02-18 04:20:34 +08:00
|
|
|
queryOptions<BusterDashboardListItem[]>({
|
|
|
|
queryKey: ['dashboard', 'list', filters] as const,
|
2025-03-13 07:12:27 +08:00
|
|
|
staleTime: 10 * 1000,
|
|
|
|
initialData: [],
|
|
|
|
initialDataUpdatedAt: 0
|
2025-02-18 04:20:34 +08:00
|
|
|
});
|
2025-02-14 05:28:45 +08:00
|
|
|
|
2025-03-26 11:56:21 +08:00
|
|
|
const dashboardGetDashboard = (dashboardId: string, version_number?: number) =>
|
2025-02-14 05:28:45 +08:00
|
|
|
queryOptions<BusterDashboardResponse>({
|
2025-03-26 11:56:21 +08:00
|
|
|
queryKey: ['dashboard', 'get', dashboardId, version_number] as const,
|
2025-02-14 05:28:45 +08:00
|
|
|
staleTime: 10 * 1000
|
|
|
|
});
|
|
|
|
|
|
|
|
export const dashboardQueryKeys = {
|
2025-03-05 00:45:55 +08:00
|
|
|
dashboardGetDashboard,
|
|
|
|
dashboardGetList
|
2025-02-14 05:28:45 +08:00
|
|
|
};
|