Skip to content

Commit

Permalink
UIBULKED-210: Improve user errors for invalid data - IncorrectTokenCo…
Browse files Browse the repository at this point in the history
…untException error (#476)
  • Loading branch information
UladzislauKutarkin authored Feb 14, 2024
1 parent 664a291 commit 4620e76
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
* [UIBULKED-351](https://issues.folio.org/browse/UIBULKED-351) Hide Query tab
* [UIBULKED-276](https://issues.folio.org/browse/UIBULKED-276) Rename "Instance" column for holdings records preview
* [UIBULKED-352](https://issues.folio.org/browse/UIBULKED-352) Localize numbers displayed in bulk edit
* [UIBULKED-210](https://issues.folio.org/browse/UIBULKED-210) Improve user errors for invalid data - IncorrectTokenCountException error.


## [3.0.5](https://github.com/folio-org/ui-bulk-edit/tree/v3.0.5) (2023-03-22)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ListSelect } from '../../../shared/ListSelect/ListSelect';
import {
CRITERIA,
EDITING_STEPS,
ERRORS,
IDENTIFIER_FILTERS,
JOB_STATUSES,
TRANSLATION_SUFFIX
Expand Down Expand Up @@ -133,11 +134,12 @@ export const IdentifierTab = () => {
identifierType: recordIdentifier,
});

const { status } = await bulkOperationStart({
const { status, errorMessage } = await bulkOperationStart({
id,
step: EDITING_STEPS.UPLOAD,
});

if (errorMessage.includes(ERRORS.TOKEN)) throw Error(ERRORS.TOKEN);
if (status === JOB_STATUSES.FAILED) throw Error();

history.replace({
Expand All @@ -147,10 +149,17 @@ export const IdentifierTab = () => {

setIsFileUploaded(true);
} catch ({ message }) {
showCallout({
message: <FormattedMessage id="ui-bulk-edit.error.uploadedFile" />,
type: 'error',
});
if (message === ERRORS.TOKEN) {
showCallout({
message: <FormattedMessage id="ui-bulk-edit.error.incorrectFormatted" values={{ fileName:fileToUpload.name }} />,
type: 'error',
});
} else {
showCallout({
message: <FormattedMessage id="ui-bulk-edit.error.uploadedFile" />,
type: 'error',
});
}
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/constants/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export const CRITERIA = {
LOGS: 'logs',
};

export const ERRORS = {
TOKEN: 'Incorrect number of tokens found in record'
};

export const TYPE_OF_PROGRESS = {
INITIAL: 'initial',
PROCESSED: 'processed',
Expand Down
1 change: 1 addition & 0 deletions translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@

"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",
Expand Down

0 comments on commit 4620e76

Please sign in to comment.