Files
dify/web/features/deployments/hooks/use-deployment-data.ts
Stephen Zhou f7014fd156 tweaks
2026-04-29 17:08:52 +08:00

29 lines
820 B
TypeScript

'use client'
import type { AppInfo } from '../types'
import { useQueries } from '@tanstack/react-query'
import { deploymentAppDataQueryOptions } from '../data'
import { useDeploymentsStore } from '../store'
type UseDeploymentDataOptions = {
enabled?: boolean
}
export function useDeploymentData(apps: AppInfo[], options: UseDeploymentDataOptions = {}) {
const { enabled = true } = options
const queries = useQueries({
queries: apps.map(app => ({
...deploymentAppDataQueryOptions(app.id),
queryFn: () => useDeploymentsStore.getState().fetchAppData(app.id),
enabled: enabled && Boolean(app.id),
})),
})
return {
isLoading: queries.some(query => query.isLoading),
isFetching: queries.some(query => query.isFetching),
isError: queries.some(query => query.isError),
}
}