Fix/upload document limit (#1033)
This commit is contained in:
parent
934def5fcc
commit
a7415ecfd8
8 changed files with 57 additions and 12 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue