Skip to content

Commit

Permalink
fix: upload document error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Usmanfee committed Sep 30, 2024
1 parent 6a45e6a commit 7520ec1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/shared/basic/Dropzone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ export const Dropzone = ({
[currentFiles, onChange, handleDelete]
)

const handleFileSizeValidator = (file: File) => {
if (maxFileSize) {
if (file.size > maxFileSize) {
return {
code: 'size-too-large',
message: `File is larger than ${(maxFileSize / 1048576).toFixed(2)} MB`,
}
}
return null
}
return null
}

const {
getRootProps,
getInputProps,
Expand All @@ -123,7 +136,7 @@ export const Dropzone = ({
maxFiles: isSingleUpload ? 0 : maxFilesToUpload,
accept: acceptFormat,
multiple: !isSingleUpload,
maxSize: maxFileSize,
validator: handleFileSizeValidator,
})

let DropAreaComponent = DefaultDropArea
Expand Down

0 comments on commit 7520ec1

Please sign in to comment.