mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: handle error delete role.
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
|
||||
import RolesFormContent from './RolesFormContent';
|
||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||
import { handleDeleteErrors } from '../utils';
|
||||
|
||||
import { compose, transformToForm } from 'utils';
|
||||
|
||||
@@ -82,8 +83,14 @@ function RolesForm({
|
||||
history.push('/preferences/users');
|
||||
};
|
||||
|
||||
const onError = (errors) => {
|
||||
const onError = ({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
setSubmitting(false);
|
||||
|
||||
handleDeleteErrors(errors);
|
||||
};
|
||||
if (isNewMode) {
|
||||
createRolePermissionMutate(form).then(onSuccess).catch(onError);
|
||||
|
||||
@@ -10,4 +10,22 @@ export const handleDeleteErrors = (errors) => {
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
if (errors.find((error) => error.type === 'INVALIDATE_PERMISSIONS')) {
|
||||
AppToaster.show({
|
||||
message: intl.get('roles.error.the_submit_role_has_invalid_permissions'),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
if (
|
||||
errors.find(
|
||||
(error) => error.type === 'CANNOT_DELETE_ROLE_ASSOCIATED_TO_USERS',
|
||||
)
|
||||
) {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
'roles.error.you_cannot_delete_role_that_associated_to_users',
|
||||
),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user