diff --git a/src/hooks/useErrorMessages.js b/src/hooks/useErrorMessages.js index cbbbdc64..1b2719c3 100644 --- a/src/hooks/useErrorMessages.js +++ b/src/hooks/useErrorMessages.js @@ -16,18 +16,18 @@ export const useErrorMessages = () => { const showErrorMessage = (res) => { const messageInBody = res?.errorMessage; const messageWhenError = res?.message; - const anyErrorMessage = messageInBody || messageWhenError; + const message = messageInBody || messageWhenError; - // check if error message should be translated (if it's code from backend + exist in translations) - const translatedMessage = intl.messages[anyErrorMessage] ? intl.formatMessage({ id: `ui-bulk-edit.error.${anyErrorMessage}` }) : ''; + // check if error message should be translated (if it's exist in translations) + const translatedMessage = intl.messages[message] ? intl.formatMessage({ id: `ui-bulk-edit.${message}` }) : ''; // show translated message if it exists if (translatedMessage) { showError(translatedMessage); // otherwise show an error message we have - } else if (anyErrorMessage) { - showError(anyErrorMessage); - // if there is no error message at all, show default error message + } else if (message) { + showError(message); + // if there is no error message but it's error instance, show sww error message } else if (res instanceof Error) { showError(intl.formatMessage({ id: 'ui-bulk-edit.error.sww' })); } diff --git a/translations/ui-bulk-edit/en.json b/translations/ui-bulk-edit/en.json index 2f818de8..7119cfee 100644 --- a/translations/ui-bulk-edit/en.json +++ b/translations/ui-bulk-edit/en.json @@ -151,10 +151,6 @@ "start.downloadChangedRecords": "Download changed records (CSV)", "start.downloadChangedRecords.marc": "Download changed records (MARC)", - "error.uploadedFile": "Fail to upload file", - "error.sww": "Something went wrong", - "error.incorrectFormatted": "{fileName} is formatted incorrectly. Please correct the formatting and upload the file again.", - "category.loanType": "Loan type", "category.location": "Location", "category.itemNotes": "Item notes", @@ -546,5 +542,8 @@ "error.mod-bulk-operations.not.upload.file.s3.invalid.configuration": "There is a problem with S3 configuration that prevents Bulk edit module to save files. Please contact your hosting provider to check if the Bulk edit app has been configured correctly.", "error.mod-bulk-operations.not.download.file.from.s3": "There is a problem to retrieve data from S3. Please contact your hosting provider to check S3 configuration. Further details are available in Bulk edit app logs (mod-bulk-operations and mod-data-export-worker modules).", "error.mod-bulk-operations.not.confirm.changes.s3.issue": "There is a problem to retrieve data from S3. Please contact your hosting provider to check S3 configuration. Further details are available in Bulk edit app logs (mod-bulk-operations and mod-data-export-worker modules).", + "error.uploadedFile": "Fail to upload file", + "error.sww": "Something went wrong", + "error.incorrectFormatted": "{fileName} is formatted incorrectly. Please correct the formatting and upload the file again.", "File uploading failed, reason: Cannot upload a file. Reason: file is empty.": "The uploaded file is empty." }