2024-12-20 14:52:20 +08:00
|
|
|
import { get } from './base'
|
2025-01-09 18:47:41 +08:00
|
|
|
import type {
|
|
|
|
FetchWorkflowDraftResponse,
|
|
|
|
} from '@/types/workflow'
|
|
|
|
import { useQuery } from '@tanstack/react-query'
|
2024-12-20 14:52:20 +08:00
|
|
|
import type { WorkflowConfigResponse } from '@/types/workflow'
|
|
|
|
|
|
|
|
const NAME_SPACE = 'workflow'
|
|
|
|
|
2025-01-09 18:47:41 +08:00
|
|
|
export const useAppWorkflow = (appID: string) => {
|
|
|
|
return useQuery<FetchWorkflowDraftResponse>({
|
|
|
|
enabled: !!appID,
|
|
|
|
queryKey: [NAME_SPACE, 'publish', appID],
|
|
|
|
queryFn: () => get<FetchWorkflowDraftResponse>(`/apps/${appID}/workflows/publish`),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-12-20 14:52:20 +08:00
|
|
|
export const useWorkflowConfig = (appId: string) => {
|
|
|
|
return useQuery({
|
|
|
|
queryKey: [NAME_SPACE, 'config', appId],
|
|
|
|
queryFn: () => get<WorkflowConfigResponse>(`/apps/${appId}/workflows/draft/config`),
|
|
|
|
})
|
|
|
|
}
|