From 1284849cfba26fda0bba17af1c0d32302e2bb443 Mon Sep 17 00:00:00 2001 From: Alexandre Titeux Date: Thu, 4 Jan 2024 09:13:31 +0100 Subject: [PATCH] :bug: Fix a bug when update user shuffle list --- src/components/dashboard/UsersManagement.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/dashboard/UsersManagement.tsx b/src/components/dashboard/UsersManagement.tsx index 5806a18..9ed4826 100644 --- a/src/components/dashboard/UsersManagement.tsx +++ b/src/components/dashboard/UsersManagement.tsx @@ -83,12 +83,12 @@ const UsersManagement: React.FC = () => { const changeRightsClick = (user: UserDto, roles: number[]) => changeRights(user.email, roles) - .then((newUser) => - setUsers((x) => [ - ...x.filter((y) => y.id != user.id), - newUser.response, - ]), - ) + .then((newUser) => { + const user = users.find((x) => x.id == newUser.response.id); + if (!user) return; + user.roles = newUser.response.roles; + setUsers([...users]); + }) .catch(() => setAlert({ content: