2025-04-24 21:26:54 +08:00
|
|
|
import { useQuery } from '@tanstack/react-query'
|
2025-07-30 15:19:10 +08:00
|
|
|
import { get } from '../base'
|
|
|
|
import type { DataSourceNotionWorkspace } from '@/models/common'
|
2025-04-24 21:26:54 +08:00
|
|
|
|
|
|
|
type PreImportNotionPagesParams = {
|
2025-07-30 15:19:10 +08:00
|
|
|
credentialId: string
|
|
|
|
datasetId: string
|
2025-04-24 21:26:54 +08:00
|
|
|
}
|
|
|
|
|
2025-07-30 15:19:10 +08:00
|
|
|
export const usePreImportNotionPages = ({
|
|
|
|
credentialId,
|
|
|
|
datasetId,
|
|
|
|
}: PreImportNotionPagesParams) => {
|
2025-04-24 21:26:54 +08:00
|
|
|
return useQuery({
|
2025-07-30 15:19:10 +08:00
|
|
|
queryKey: ['notion-pre-import-pages', credentialId, datasetId],
|
2025-04-24 21:26:54 +08:00
|
|
|
queryFn: async () => {
|
2025-07-30 15:19:10 +08:00
|
|
|
return get<{ notion_info: DataSourceNotionWorkspace[] }>('/notion/pre-import/pages', {
|
|
|
|
params: {
|
|
|
|
dataset_id: datasetId,
|
|
|
|
credential_id: credentialId,
|
|
|
|
},
|
|
|
|
})
|
2025-04-24 21:26:54 +08:00
|
|
|
},
|
2025-07-30 15:19:10 +08:00
|
|
|
retry: 0,
|
2025-04-24 21:26:54 +08:00
|
|
|
})
|
|
|
|
}
|