From e8183cc4f32d7f5d67821d31c49ef16305606de6 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 24 Sep 2024 13:34:56 +0800 Subject: [PATCH] Fixed hardcoded array access --- Client/src/Components/Sidebar/index.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index 1333b6f67..aa80e0c85 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -93,8 +93,9 @@ function Sidebar() { const { user } = useSelector((state) => state.auth); // Remove demo password if demo - if (user.role?.includes("demo")) { - menu[3].nested = menu[3].nested.filter((item) => { + const accountMenuItem = menu.find((item) => item.name === "account"); + if (user.role?.includes("demo") && accountMenuItem) { + accountMenuItem.nested = accountMenuItem.nested.filter((item) => { return item.name !== "Password"; }); }