Skip to content

Commit

Permalink
fix: onDrop validation
Browse files Browse the repository at this point in the history
  • Loading branch information
issambaccouch authored Oct 27, 2023
1 parent 155706a commit 0ccda69
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions JeMPI_Apps/JeMPI_UI/src/components/import/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,24 @@ const DropZone: FC = () => {
acceptedFiles: File[],
fileRejections: FileRejection[]
): void => {
validate(fileRejections)
setFilesObj({
file: acceptedFiles[0],
progress: 0,
status: UploadStatus.Pending
})
if (validate(fileRejections)) {
setFilesObj({
file: acceptedFiles[0],
progress: 0,
status: UploadStatus.Pending
});
}
}

const validate = (fileRejections: FileRejection[]): void => {
const validate = (fileRejections: FileRejection[]): boolean => {
if (fileRejections.length > 0) {
enqueueSnackbar(fileRejections[0].errors[0].message, {
variant: 'error'
})
return
});
return false;
}
}
return true;
};

const { getRootProps, getInputProps } = useDropzone({
accept: { 'text/csv': ['.csv'] },
Expand Down

0 comments on commit 0ccda69

Please sign in to comment.