diff --git a/client/src/containers/Items/ItemsList.js b/client/src/containers/Items/ItemsList.js index 32844816d..6f034cf9b 100644 --- a/client/src/containers/Items/ItemsList.js +++ b/client/src/containers/Items/ItemsList.js @@ -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]); diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index ae209dffe..3b4bffaf8 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -814,5 +814,6 @@ export default { item_code: 'Item code', quantity_on_hand: 'Quantity on hand', average_rate: 'Average rate', - the_name_used_before: 'The name is already used.' + the_name_used_before: 'The name is already used.', + the_item_has_associated_transactions: 'The item has associated transactions.' }; diff --git a/client/src/store/items/items.actions.js b/client/src/store/items/items.actions.js index bbffc11fd..20e634bb4 100644 --- a/client/src/store/items/items.actions.js +++ b/client/src/store/items/items.actions.js @@ -80,7 +80,7 @@ export const deleteItem = ({ id }) => { resolve(response); }) .catch((error) => { - reject(error); + reject(error?.response?.data); }); }); };