diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index a8648425a51..99255922927 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -171,22 +171,14 @@ export default function ManageUsers() { }; const showDelete = (user: any) => { - const STATE_ADMIN_LEVEL = USER_TYPES.indexOf("StateAdmin"); - const STATE_READ_ONLY_ADMIN_LEVEL = - USER_TYPES.indexOf("StateReadOnlyAdmin"); - const DISTRICT_ADMIN_LEVEL = USER_TYPES.indexOf("DistrictAdmin"); - const level = USER_TYPES.indexOf(user.user_type); - const currentUserLevel = USER_TYPES.indexOf(currentUser.data.user_type); if (user.is_superuser) return true; - if (currentUserLevel >= STATE_ADMIN_LEVEL) - return user.state_object?.id === currentUser?.data?.state; if ( - currentUserLevel < STATE_READ_ONLY_ADMIN_LEVEL && - currentUserLevel >= DISTRICT_ADMIN_LEVEL && - currentUserLevel > level + USER_TYPES.indexOf(currentUser.data.user_type) >= + USER_TYPES.indexOf("StateAdmin") ) - return user?.district_object?.id === currentUser?.data?.district; + return user.state_object?.id === currentUser?.data?.state; + return false; }; @@ -253,13 +245,14 @@ export default function ManageUsers() { > ) : null} {showDelete(user) && ( - + )}