dify/web/service/knowledge/use-import.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

38 lines
1.0 KiB
TypeScript

import type { DataSourceNotionWorkspace } from '@/models/common'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { get } from '../base'
type PreImportNotionPagesParams = {
datasetId: string
credentialId: string
}
const PRE_IMPORT_NOTION_PAGES_QUERY_KEY = 'notion-pre-import-pages'
export const usePreImportNotionPages = ({
datasetId,
credentialId,
}: PreImportNotionPagesParams) => {
return useQuery({
queryKey: [PRE_IMPORT_NOTION_PAGES_QUERY_KEY, datasetId, credentialId],
queryFn: async () => {
return get<{ notion_info: DataSourceNotionWorkspace[] }>('/notion/pre-import/pages', {
params: {
dataset_id: datasetId,
credential_id: credentialId,
},
})
},
retry: 0,
})
}
export const useInvalidPreImportNotionPages = () => {
const queryClient = useQueryClient()
return ({ datasetId, credentialId }: PreImportNotionPagesParams) => {
queryClient.invalidateQueries({
queryKey: [PRE_IMPORT_NOTION_PAGES_QUERY_KEY, datasetId, credentialId],
})
}
}