Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 17, 2024
1 parent 17a1389 commit 9d3c4ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/hooks/useErrorMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }));
}
Expand Down
7 changes: 3 additions & 4 deletions translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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."
}

0 comments on commit 9d3c4ac

Please sign in to comment.