fix
This commit is contained in:
parent
d01011c266
commit
c0ea55f77c
@ -49,7 +49,24 @@ const AdminUsersPage = () => {
|
|||||||
console.error(error);
|
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 = () => {
|
const copyToClipboard = () => {
|
||||||
if (inviteLink) {
|
if (inviteLink) {
|
||||||
navigator.clipboard.writeText(inviteLink).then(() => {
|
navigator.clipboard.writeText(inviteLink).then(() => {
|
||||||
@ -83,7 +100,7 @@ const AdminUsersPage = () => {
|
|||||||
try {
|
try {
|
||||||
await userApi.deleteUser(userId);
|
await userApi.deleteUser(userId);
|
||||||
setUsers(users.filter(user => user.id !== userId));
|
setUsers(users.filter(user => user.id !== userId));
|
||||||
if(userId===currentUser.id){
|
if(userId===getUserId(currentUser)){
|
||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user