fix
This commit is contained in:
parent
d01011c266
commit
c0ea55f77c
@ -49,7 +49,24 @@ const AdminUsersPage = () => {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const getUserId = (user) => {
|
||||
if (!user) return '';
|
||||
|
||||
if (typeof user === 'number') return String(user);
|
||||
if (typeof user === 'string') {
|
||||
return /^\d+$/.test(user) ? user : '';
|
||||
}
|
||||
|
||||
return String(
|
||||
user.id ??
|
||||
user.pk ??
|
||||
user.user_id ??
|
||||
user.userId ??
|
||||
user.user?.id ??
|
||||
user.user?.pk ??
|
||||
''
|
||||
);
|
||||
};
|
||||
const copyToClipboard = () => {
|
||||
if (inviteLink) {
|
||||
navigator.clipboard.writeText(inviteLink).then(() => {
|
||||
@ -83,7 +100,7 @@ const AdminUsersPage = () => {
|
||||
try {
|
||||
await userApi.deleteUser(userId);
|
||||
setUsers(users.filter(user => user.id !== userId));
|
||||
if(userId===currentUser.id){
|
||||
if(userId===getUserId(currentUser)){
|
||||
logout();
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user