dify/web/service/use-try-app.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

55 lines
1.4 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { consoleQuery } from '@/service/client'
import {
fetchTryAppDatasets,
fetchTryAppFlowPreview,
fetchTryAppInfo,
fetchTryAppParams,
} from './try-app'
export const useGetTryAppInfo = (appId: string) => {
return useQuery({
queryKey: consoleQuery.trialApps.byAppId.get.queryKey({ input: { params: { app_id: appId } } }),
queryFn: () => {
return fetchTryAppInfo(appId)
},
enabled: !!appId,
})
}
export const useGetTryAppParams = (appId: string) => {
return useQuery({
queryKey: consoleQuery.trialApps.byAppId.parameters.get.queryKey({
input: { params: { app_id: appId } },
}),
queryFn: () => {
return fetchTryAppParams(appId)
},
enabled: !!appId,
})
}
export const useGetTryAppDataSets = (appId: string, ids: string[]) => {
return useQuery({
queryKey: consoleQuery.trialApps.byAppId.datasets.get.queryKey({
input: { params: { app_id: appId }, query: { ids } },
}),
queryFn: () => {
return fetchTryAppDatasets(appId, ids)
},
enabled: ids.length > 0,
})
}
export const useGetTryAppFlowPreview = (appId: string, disabled?: boolean) => {
return useQuery({
queryKey: consoleQuery.trialApps.byAppId.workflows.get.queryKey({
input: { params: { app_id: appId } },
}),
enabled: !disabled,
queryFn: () => {
return fetchTryAppFlowPreview(appId)
},
})
}