dify/web/service/use-workflow.ts
2024-11-15 10:43:21 +08:00

19 lines
546 B
TypeScript

import { get } from './base'
import type {
FetchWorkflowDraftResponse,
} from '@/types/workflow'
import { useQuery } from '@tanstack/react-query'
const NAME_SPACE = 'workflow'
export const useAppWorkflow = (appID: string) => {
return useQuery<FetchWorkflowDraftResponse>({
queryKey: [NAME_SPACE, 'publish', appID],
queryFn: () => {
if (appID === 'empty')
return Promise.resolve({} as unknown as FetchWorkflowDraftResponse)
return get<FetchWorkflowDraftResponse>(`/apps/${appID}/workflows/publish`)
},
})
}