fix: handle delete items error.

This commit is contained in:
Ahmed Bouhuolia
2020-11-10 20:32:59 +02:00
parent 94b97af3a9
commit aabd42a7a1
3 changed files with 13 additions and 2 deletions

View File

@@ -97,6 +97,16 @@ function ItemsList({
intent: Intent.SUCCESS,
});
setDeleteItem(false);
}).catch(({ errors }) => {
if (errors.find(error => error.type === 'ITEM_HAS_ASSOCIATED_TRANSACTINS')) {
AppToaster.show({
message: formatMessage({
id: 'the_item_has_associated_transactions',
}),
intent: Intent.DANGER,
});
}
setDeleteItem(false);
});
}, [requestDeleteItem, deleteItem, formatMessage]);