From bd3059ecd88a1d73c9ece59bfe79b3a89bad93e1 Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Sun, 13 Mar 2022 15:20:00 +0200 Subject: [PATCH] feat(branches & warehouses): handle errors. --- src/containers/Preferences/Branches/utils.js | 6 ++++++ src/containers/Preferences/Warehouses/utils.js | 8 ++++++++ src/containers/Sales/Receipts/ReceiptForm/ReceiptForm.js | 2 +- src/lang/en/index.json | 6 ++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/containers/Preferences/Branches/utils.js b/src/containers/Preferences/Branches/utils.js index 29dc536b3..88026031b 100644 --- a/src/containers/Preferences/Branches/utils.js +++ b/src/containers/Preferences/Branches/utils.js @@ -12,4 +12,10 @@ export const handleDeleteErrors = (errors) => { intent: Intent.DANGER, }); } + if (errors.some((e) => e.type === 'BRANCH_HAS_ASSOCIATED_TRANSACTIONS')) { + AppToaster.show({ + message: intl.get('branche.error.branch_has_associated_transactions'), + intent: Intent.DANGER, + }); + } }; diff --git a/src/containers/Preferences/Warehouses/utils.js b/src/containers/Preferences/Warehouses/utils.js index 7883d8994..7a852f6dd 100644 --- a/src/containers/Preferences/Warehouses/utils.js +++ b/src/containers/Preferences/Warehouses/utils.js @@ -14,4 +14,12 @@ export const handleDeleteErrors = (errors) => { intent: Intent.DANGER, }); } + if (errors.some((e) => e.type === 'WAREHOUSE_HAS_ASSOCIATED_TRANSACTIONS')) { + AppToaster.show({ + message: intl.get( + 'warehouse.error.warehouse_has_associated_transactions', + ), + intent: Intent.DANGER, + }); + } }; diff --git a/src/containers/Sales/Receipts/ReceiptForm/ReceiptForm.js b/src/containers/Sales/Receipts/ReceiptForm/ReceiptForm.js index 129b6cec3..f91edb26e 100644 --- a/src/containers/Sales/Receipts/ReceiptForm/ReceiptForm.js +++ b/src/containers/Sales/Receipts/ReceiptForm/ReceiptForm.js @@ -19,7 +19,7 @@ import ReceiptItemsEntriesEditor from './ReceiptItemsEntriesEditor'; import ReceiptFormFloatingActions from './ReceiptFormFloatingActions'; import ReceiptFormFooter from './ReceiptFormFooter'; import ReceiptFormDialogs from './ReceiptFormDialogs'; -import ReceiptFormTopBar from './ReceiptFormTopBar'; +import ReceiptFormTopBar from './ReceiptFormTopbar'; import withDashboardActions from 'containers/Dashboard/withDashboardActions'; import withSettings from 'containers/Settings/withSettings'; diff --git a/src/lang/en/index.json b/src/lang/en/index.json index 6b3b06cac..f01e869c9 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -1898,6 +1898,8 @@ "vendor_opening_balance.label.opening_balance_at": "Opening balance at", "customer.label.opening_branch": "Opening Balance Branch", "vendor.label.opening_branch": "Opening Balance Branch", - "warehouse.error.warehouse_code_not_unique":"Warehouse code not unique", - "branche.error.warehouse_code_not_unique":"Branch code not unique" + "warehouse.error.warehouse_code_not_unique": "Warehouse code not unique", + "warehouse.error.warehouse_has_associated_transactions": "You could not delete the warehouse that has associated transactions.", + "branche.error.warehouse_code_not_unique": "Branch code not unique", + "branche.error.branch_has_associated_transactions": "You could not delete the branch that has associated transactions." } \ No newline at end of file