|
@@ -1,5 +1,6 @@
|
|
|
'use client'
|
|
|
import React, { useMemo, useState } from 'react'
|
|
|
+import useSWR from 'swr'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import cn from 'classnames'
|
|
|
import FilePreview from '../file-preview'
|
|
@@ -13,6 +14,7 @@ import { DataSourceType } from '@/models/datasets'
|
|
|
import Button from '@/app/components/base/button'
|
|
|
import { NotionPageSelector } from '@/app/components/base/notion-page-selector'
|
|
|
import { useDatasetDetailContext } from '@/context/dataset-detail'
|
|
|
+import { fetchDocumentsLimit } from '@/service/common'
|
|
|
|
|
|
type IStepOneProps = {
|
|
|
datasetId?: string
|
|
@@ -61,6 +63,7 @@ const StepOne = ({
|
|
|
notionPages = [],
|
|
|
updateNotionPages,
|
|
|
}: IStepOneProps) => {
|
|
|
+ const { data: limitsData } = useSWR('/datasets/limit', fetchDocumentsLimit)
|
|
|
const { dataset } = useDatasetDetailContext()
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
const [currentFile, setCurrentFile] = useState<File | undefined>()
|
|
@@ -151,7 +154,7 @@ const StepOne = ({
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
- {dataSourceType === DataSourceType.FILE && (
|
|
|
+ {dataSourceType === DataSourceType.FILE && limitsData && (
|
|
|
<>
|
|
|
<FileUploader
|
|
|
fileList={files}
|
|
@@ -160,6 +163,8 @@ const StepOne = ({
|
|
|
onFileListUpdate={updateFileList}
|
|
|
onFileUpdate={updateFile}
|
|
|
onPreview={updateCurrentFile}
|
|
|
+ countLimit={limitsData.documents_limit}
|
|
|
+ countUsed={limitsData.documents_count}
|
|
|
/>
|
|
|
<Button disabled={nextDisabled} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>
|
|
|
</>
|
|
@@ -167,10 +172,16 @@ const StepOne = ({
|
|
|
{dataSourceType === DataSourceType.NOTION && (
|
|
|
<>
|
|
|
{!hasConnection && <NotionConnector onSetting={onSetting} />}
|
|
|
- {hasConnection && (
|
|
|
+ {hasConnection && limitsData && (
|
|
|
<>
|
|
|
<div className='mb-8 w-[640px]'>
|
|
|
- <NotionPageSelector value={notionPages.map(page => page.page_id)} onSelect={updateNotionPages} onPreview={updateCurrentPage} />
|
|
|
+ <NotionPageSelector
|
|
|
+ value={notionPages.map(page => page.page_id)}
|
|
|
+ onSelect={updateNotionPages}
|
|
|
+ onPreview={updateCurrentPage}
|
|
|
+ countLimit={limitsData.documents_limit}
|
|
|
+ countUsed={limitsData.documents_count}
|
|
|
+ />
|
|
|
</div>
|
|
|
<Button disabled={!notionPages.length} className={s.submitButton} type='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>
|
|
|
</>
|