chore: more specific error message while removing Admin status
Action leading to a scenario where there are no users with Admin privileges.
This commit is contained in:
@@ -164,6 +164,7 @@
|
|||||||
"privacy_policy": "Privacy Policy",
|
"privacy_policy": "Privacy Policy",
|
||||||
"reenter_email": "Re-enter email",
|
"reenter_email": "Re-enter email",
|
||||||
"remove_admin_failure": "Failed to remove admin status!!",
|
"remove_admin_failure": "Failed to remove admin status!!",
|
||||||
|
"remove_admin_failure_only_one_admin": "Failed to remove admin status. There should be at least one admin!!",
|
||||||
"remove_admin_success": "Admin status removed!!",
|
"remove_admin_success": "Admin status removed!!",
|
||||||
"remove_admin_from_users_failure": "Failed to remove admin status from selected users!!",
|
"remove_admin_from_users_failure": "Failed to remove admin status from selected users!!",
|
||||||
"remove_admin_from_users_success": "Admin status removed from selected users!!",
|
"remove_admin_from_users_success": "Admin status removed from selected users!!",
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ export const UNAUTHORIZED = 'Unauthorized' as const;
|
|||||||
// Sometimes the backend returns Unauthorized error message as follows:
|
// Sometimes the backend returns Unauthorized error message as follows:
|
||||||
export const GRAPHQL_UNAUTHORIZED = '[GraphQL] Unauthorized' as const;
|
export const GRAPHQL_UNAUTHORIZED = '[GraphQL] Unauthorized' as const;
|
||||||
|
|
||||||
export const DELETE_USER_FAILED_ONLY_ONE_ADMIN =
|
export const ONLY_ONE_ADMIN_ACCOUNT_FOUND =
|
||||||
'admin/only_one_admin_account_found' as const;
|
'[GraphQL] admin/only_one_admin_account_found' as const;
|
||||||
|
|
||||||
export const ADMIN_CANNOT_BE_DELETED =
|
export const ADMIN_CANNOT_BE_DELETED =
|
||||||
'admin/admin_can_not_be_deleted' as const;
|
'admin/admin_can_not_be_deleted' as const;
|
||||||
|
|||||||
@@ -258,7 +258,10 @@ import {
|
|||||||
UsersListQuery,
|
UsersListQuery,
|
||||||
UsersListV2Document,
|
UsersListV2Document,
|
||||||
} from '~/helpers/backend/graphql';
|
} from '~/helpers/backend/graphql';
|
||||||
import { USER_ALREADY_INVITED } from '~/helpers/errors';
|
import {
|
||||||
|
ONLY_ONE_ADMIN_ACCOUNT_FOUND,
|
||||||
|
USER_ALREADY_INVITED,
|
||||||
|
} from '~/helpers/errors';
|
||||||
import { handleUserDeletion } from '~/helpers/userManagement';
|
import { handleUserDeletion } from '~/helpers/userManagement';
|
||||||
import IconCheck from '~icons/lucide/check';
|
import IconCheck from '~icons/lucide/check';
|
||||||
import IconLeft from '~icons/lucide/chevron-left';
|
import IconLeft from '~icons/lucide/chevron-left';
|
||||||
@@ -525,6 +528,10 @@ const makeAdminsToUsers = async (id: string | null) => {
|
|||||||
const variables = { userUIDs };
|
const variables = { userUIDs };
|
||||||
const result = await adminsToUser.executeMutation(variables);
|
const result = await adminsToUser.executeMutation(variables);
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
|
if (result.error.message === ONLY_ONE_ADMIN_ACCOUNT_FOUND) {
|
||||||
|
return toast.error(t('state.remove_admin_failure_only_one_admin'));
|
||||||
|
}
|
||||||
|
|
||||||
toast.error(
|
toast.error(
|
||||||
areMultipleUsersSelected.value
|
areMultipleUsersSelected.value
|
||||||
? t('state.remove_admin_from_users_failure')
|
? t('state.remove_admin_from_users_failure')
|
||||||
|
|||||||
Reference in New Issue
Block a user