Files
dify/web/service/knowledge/use-import.ts
2026-01-02 18:48:52 +08:00

37 lines
920 B
TypeScript

import { useQuery, useQueryClient } from '@tanstack/react-query'
import { fetchPreImportNotionPages } from '../datasets'
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 fetchPreImportNotionPages({ datasetId, credentialId })
},
retry: 0,
})
}
export const useInvalidPreImportNotionPages = () => {
const queryClient = useQueryClient()
return ({
datasetId,
credentialId,
}: PreImportNotionPagesParams) => {
queryClient.invalidateQueries(
{
queryKey: [PRE_IMPORT_NOTION_PAGES_QUERY_KEY, datasetId, credentialId],
},
)
}
}