From bb5a1959d0062c538b0710d6261e769c99dd0a77 Mon Sep 17 00:00:00 2001 From: Abhimanue Date: Sun, 13 Oct 2024 10:36:00 +0530 Subject: [PATCH] refractor code --- Client/src/Components/Sidebar/index.jsx | 42 +++++++++---------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index bb2097944..be7689235 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -71,12 +71,18 @@ const menu = [ ]; const other = [ - { name: "Support", path: "support", icon: }, { name: "Settings", path: "settings", icon: }, + { name: "Support", path: "support", icon: }, { name: "Docs", path: "docs", icon: }, { name: "Changelog", path: "changelog", icon: }, ]; +const URL_MAP = { + support: "https://github.com/bluewave-labs/bluewave-uptime/issues", + docs: "https://bluewavelabs.gitbook.io/uptime-manager", + changelog: "https://github.com/bluewave-labs/bluewave-uptime/releases", +}; + /** * @component * Sidebar component serves as a sidebar containing a menu. @@ -502,34 +508,14 @@ function Sidebar() { className={ location.pathname.includes(item.path) ? "selected-path" : "" } - onClick={ - () => { - if (item.path === "support") { - window.open( - "https://github.com/bluewave-labs/bluewave-uptime/issues", - "_blank", - "noreferrer" - ); - } - else if(item.path === "docs"){ - window.open( - "https://bluewavelabs.gitbook.io/uptime-manager", - "_blank", - "noreferrer" - ) - } - else if(item.path === "changelog"){ - window.open( - "https://github.com/bluewave-labs/bluewave-uptime/releases", - "_blank", - "noreferrer" - ) - } - else{ - navigate(`/${item.path}`) - } + onClick={() => { + const url = URL_MAP[item.path]; + if (url) { + window.open(url, "_blank", "noreferrer"); + } else { + navigate(`/${item.path}`); } - } + }} sx={{ gap: theme.spacing(4), borderRadius: theme.shape.borderRadius,