Fix/upload document limit (#1033)
This commit is contained in:
@@ -18,6 +18,8 @@ type IFileUploaderProps = {
|
||||
onFileUpdate: (fileItem: FileItem, progress: number, list: FileItem[]) => void
|
||||
onFileListUpdate?: (files: any) => void
|
||||
onPreview: (file: File) => void
|
||||
countLimit: number
|
||||
countUsed: number
|
||||
}
|
||||
|
||||
const ACCEPTS = [
|
||||
@@ -39,6 +41,8 @@ const FileUploader = ({
|
||||
onFileUpdate,
|
||||
onFileListUpdate,
|
||||
onPreview,
|
||||
countLimit,
|
||||
countUsed,
|
||||
}: IFileUploaderProps) => {
|
||||
const { t } = useTranslation()
|
||||
const { notify } = useContext(ToastContext)
|
||||
@@ -145,6 +149,10 @@ const FileUploader = ({
|
||||
const initialUpload = useCallback((files: File[]) => {
|
||||
if (!files.length)
|
||||
return false
|
||||
if (files.length > countLimit - countUsed) {
|
||||
notify({ type: 'error', message: t('datasetCreation.stepOne.overCountLimit', { countLimit }) })
|
||||
return false
|
||||
}
|
||||
const preparedFiles = files.map((file, index) => ({
|
||||
fileID: `file${index}-${Date.now()}`,
|
||||
file,
|
||||
|
Reference in New Issue
Block a user