Skip to content

Commit

Permalink
Add error handling for event definition delete bulk action
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiadlovskii committed Dec 27, 2024
1 parent f1c71e6 commit 2b1f362
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,16 @@ const BulkActions = () => {
};

const onAction = useCallback(() => {
const descriptor = StringUtils.pluralize(selectedItemsAmount, 'event definition', 'event definitions');

fetch('POST',
qualifyUrl(ACTION_TEXT[actionType].bulkActionUrl),
{ entity_ids: selectedEntities },
).then(({ failures }) => {
if (failures?.length) {
const notUpdatedDefinitionIds = failures.map(({ entity_id }) => entity_id);
setSelectedEntities(notUpdatedDefinitionIds);
UserNotification.error(`${notUpdatedDefinitionIds.length} out of ${selectedItemsAmount} selected ${descriptor} could not be deleted.`);
} else {
setSelectedEntities([]);
UserNotification.success(`${selectedItemsAmount} ${getDescriptor(selectedItemsAmount)} ${StringUtils.pluralize(selectedItemsAmount, 'was', 'were')} ${actionType}d successfully.`, 'Success');
Expand Down

0 comments on commit 2b1f362

Please sign in to comment.