mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat(warehouse & Branch): handle error.
This commit is contained in:
@@ -5,6 +5,7 @@ import { Intent, Alert } from '@blueprintjs/core';
|
|||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
|
|
||||||
import { useDeleteBranch } from 'hooks/query';
|
import { useDeleteBranch } from 'hooks/query';
|
||||||
|
import { handleDeleteErrors } from '../../Preferences/Branches/utils';
|
||||||
|
|
||||||
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||||
@@ -24,7 +25,6 @@ function BranchDeleteAlert({
|
|||||||
// #withAlertActions
|
// #withAlertActions
|
||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const { mutateAsync: deleteBranch, isLoading } = useDeleteBranch();
|
const { mutateAsync: deleteBranch, isLoading } = useDeleteBranch();
|
||||||
|
|
||||||
// Handle cancel delete alert.
|
// Handle cancel delete alert.
|
||||||
@@ -46,7 +46,9 @@ function BranchDeleteAlert({
|
|||||||
response: {
|
response: {
|
||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {},
|
}) => {
|
||||||
|
handleDeleteErrors(errors);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
|
|||||||
import { Intent, Alert } from '@blueprintjs/core';
|
import { Intent, Alert } from '@blueprintjs/core';
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
import { useDeleteWarehouse } from 'hooks/query';
|
import { useDeleteWarehouse } from 'hooks/query';
|
||||||
|
import { handleDeleteErrors } from '../../Preferences/Warehouses/utils';
|
||||||
|
|
||||||
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||||
@@ -46,7 +47,9 @@ function WarehouseDeleteAlert({
|
|||||||
response: {
|
response: {
|
||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {},
|
}) => {
|
||||||
|
handleDeleteErrors(errors);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
|
|||||||
15
src/containers/Preferences/Branches/utils.js
Normal file
15
src/containers/Preferences/Branches/utils.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { AppToaster } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle delete errors.
|
||||||
|
*/
|
||||||
|
export const handleDeleteErrors = (errors) => {
|
||||||
|
if (errors.find((error) => error.type === 'COULD_NOT_DELETE_ONLY_BRANCH')) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: intl.get('branch.error.could_not_delete_only_branch'),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
17
src/containers/Preferences/Warehouses/utils.js
Normal file
17
src/containers/Preferences/Warehouses/utils.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { AppToaster } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle delete errors.
|
||||||
|
*/
|
||||||
|
export const handleDeleteErrors = (errors) => {
|
||||||
|
if (
|
||||||
|
errors.find((error) => error.type === 'COULD_NOT_DELETE_ONLY_WAERHOUSE')
|
||||||
|
) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: intl.get('warehouse.error.could_not_delete_only_waerhouse'),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1800,6 +1800,7 @@
|
|||||||
"warehouses.action.make_as_parimary": "Mark as Primary",
|
"warehouses.action.make_as_parimary": "Mark as Primary",
|
||||||
"warehouse.alert.delete_message": "The warehouse has been deleted successfully",
|
"warehouse.alert.delete_message": "The warehouse has been deleted successfully",
|
||||||
"warehouse.once_delete_this_warehouse": "Once you delete this warehouse, you won't be able to restore it later. Are you sure you want to delete this warehouse?",
|
"warehouse.once_delete_this_warehouse": "Once you delete this warehouse, you won't be able to restore it later. Are you sure you want to delete this warehouse?",
|
||||||
|
"warehouse.error.could_not_delete_only_waerhouse":"You could not delete the only warehouse.",
|
||||||
"sidebar_warehouse_transfer": "Warehouse Transfers",
|
"sidebar_warehouse_transfer": "Warehouse Transfers",
|
||||||
"warehouse_transfer.label.transfer_no": "Transfer No",
|
"warehouse_transfer.label.transfer_no": "Transfer No",
|
||||||
"warehouse_transfer.label.form_warehouse": "Form Warehouse",
|
"warehouse_transfer.label.form_warehouse": "Form Warehouse",
|
||||||
@@ -1862,6 +1863,7 @@
|
|||||||
"branch_activate.dialog_success_message": "Multi-branches feature has been activated successfully.",
|
"branch_activate.dialog_success_message": "Multi-branches feature has been activated successfully.",
|
||||||
"branch.alert.mark_primary_message": "The branch has been marked as primary.",
|
"branch.alert.mark_primary_message": "The branch has been marked as primary.",
|
||||||
"branch.alert.are_you_sure_you_want_to_make": "Are you sure you want to make a primary branch?",
|
"branch.alert.are_you_sure_you_want_to_make": "Are you sure you want to make a primary branch?",
|
||||||
|
"branch.error.could_not_delete_only_branch": "You could not delete the only branch.",
|
||||||
"warehouse_activate.dialog_success_message": "Multi-branches feature has been activated successfully.",
|
"warehouse_activate.dialog_success_message": "Multi-branches feature has been activated successfully.",
|
||||||
"warehouse.alert.mark_primary_message": "The given warehouse has been marked as primary.",
|
"warehouse.alert.mark_primary_message": "The given warehouse has been marked as primary.",
|
||||||
"warehouse.alert.are_you_sure_you_want_to_make": "Are you sure you want to make a primary warehouse?",
|
"warehouse.alert.are_you_sure_you_want_to_make": "Are you sure you want to make a primary warehouse?",
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
.dialog--quick-payment-receive {
|
.dialog--quick-payment-receive {
|
||||||
.bp3-dialog-body {
|
.bp3-dialog-body {
|
||||||
line-height: 10px;
|
line-height: 14px;
|
||||||
.bp3-form-group {
|
.bp3-form-group {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 13px;
|
||||||
|
|
||||||
label.bp3-label {
|
label.bp3-label {
|
||||||
margin-bottom: 7px;
|
margin-bottom: 3px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bp3-dialog-footer {
|
.bp3-dialog-footer {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user