{i18next.t("Uploading the selected files would result in")}{" "}
@@ -138,35 +138,43 @@ export const FileUploaderComponent = ({
/>
);
- } else if (!_isEmpty(duplicateFiles)) {
- setWarningMsg(
-
+ } else {
+ let warnings = [];
+
+ if (hasDuplicateFiles) {
+ warnings.push(
-
- );
- } else {
+ );
+ }
+
if (!allowEmptyFiles && hasEmptyFiles) {
- setWarningMsg(
-
-
-
+ warnings.push(
+
);
}
- // Proceed with uploading the non-empty files or all files if empty files are allowed
- if (allowEmptyFiles || hasNonEmptyFiles) {
- uploadFiles(formikDraft, allowEmptyFiles ? acceptedFiles : nonEmptyFiles);
+ if (!_isEmpty(warnings)) {
+ setWarningMsg({warnings}
);
+ }
+
+ const filesToUpload = allowEmptyFiles
+ ? [...nonEmptyFiles, ...emptyFiles]
+ : nonEmptyFiles;
+
+ // Proceed with uploading files if there are any to upload
+ if (!_isEmpty(filesToUpload)) {
+ uploadFiles(formikDraft, filesToUpload);
}
}
},