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:
jamesgeorge007
2024-03-27 14:45:19 +05:30
parent 17db483a35
commit 8a8cdcf78b
3 changed files with 11 additions and 3 deletions

View File

@@ -258,7 +258,10 @@ import {
UsersListQuery,
UsersListV2Document,
} 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 IconCheck from '~icons/lucide/check';
import IconLeft from '~icons/lucide/chevron-left';
@@ -525,6 +528,10 @@ const makeAdminsToUsers = async (id: string | null) => {
const variables = { userUIDs };
const result = await adminsToUser.executeMutation(variables);
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(
areMultipleUsersSelected.value
? t('state.remove_admin_from_users_failure')