mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00: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,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1496,5 +1496,6 @@
|
||||
"roles.permission_schema.once_delete_this_role_you_will_able_to_restore_it":"بمجرد حذف دور المستخدم ، لن تتمكن من استعادتها لاحقًا. هل أنت متأكد أنك تريد حذف هذا الدور؟",
|
||||
"users.column.role_name":"دور المستخدم",
|
||||
"roles.error.you_cannot_edit_predefined_roles":"لا يمكنك تعديل أدوار المستخدم المحددة مسبقا.",
|
||||
"roles.error.you_cannot_delete_predefined_roles":"لا يمكنك حذف أدوار المستخدم المحددة مسبقا"
|
||||
"roles.error.you_cannot_delete_predefined_roles":"لا يمكنك حذف أدوار المستخدم المحددة مسبقا",
|
||||
"roles.error.you_cannot_delete_role_that_associated_to_users":"لا يمكن حذف دور المستخدم لأنه لديه مستخدمين مرتبطة به."
|
||||
}
|
||||
@@ -1485,5 +1485,7 @@
|
||||
"roles.permission_schema.once_delete_this_role_you_will_able_to_restore_it":"Once you delete this role, you won't be able to restore it later. Are you sure you want to delete this role?",
|
||||
"users.column.role_name":"Role Name",
|
||||
"roles.error.you_cannot_edit_predefined_roles":"You cannot edit predefined roles.",
|
||||
"roles.error.you_cannot_delete_predefined_roles":"You cannot delete predefined roles."
|
||||
"roles.error.you_cannot_delete_predefined_roles":"You cannot delete predefined roles.",
|
||||
"roles.error.the_submit_role_has_invalid_permissions":"The submit role has invalid permissions.",
|
||||
"roles.error.you_cannot_delete_role_that_associated_to_users":"You cannot delete role that associated to users"
|
||||
}
|
||||
Reference in New Issue
Block a user