Skip to content

Commit

Permalink
#1178 | fix: consolidate alert
Browse files Browse the repository at this point in the history
  • Loading branch information
vedfordev committed Dec 13, 2024
1 parent 3cc06e4 commit f41340b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dataEntryApp/components/MediaUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ function removeMediaUrlFromLocalObsValue(update, fileName, isMultiSelect, localO
}
}

function consolidateAlerts(etFiles, formElement, isFileDataType, alerts) {
function consolidateAlerts(etFiles, formElement, isFileDataType) {
const alerts = [];
etFiles.forEach(file => {
if (!isValidType(formElement, file.type, isFileDataType)) {
alerts.push(`Selected files type not supported for file ${file.name}. Please choose proper files.\n`);
Expand All @@ -124,6 +125,7 @@ function consolidateAlerts(etFiles, formElement, isFileDataType, alerts) {
);
}
});
return alerts;
}

function uploadMediaAndUpdateObservationValue(
Expand Down Expand Up @@ -185,9 +187,8 @@ export const MediaUploader = ({ label, obsValue, mediaType, update, formElement
}, [openImage]);

const onMediaSelect = event => {
const alerts = [];
const etFiles = Array.from(event.target.files);
consolidateAlerts(etFiles, formElement, isFileDataType, alerts);
const alerts = consolidateAlerts(etFiles, formElement, isFileDataType);
if (!isEmpty(alerts)) {
alert(alerts);
return;
Expand Down

0 comments on commit f41340b

Please sign in to comment.