diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index be7689235..4e62bffe5 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -43,6 +43,7 @@ import ArrowLeft from "../../assets/icons/left-arrow.svg?react"; import DotsVertical from "../../assets/icons/dots-vertical.svg?react"; import ChangeLog from "../../assets/icons/changeLog.svg?react"; import Docs from "../../assets/icons/docs.svg?react"; +import Folder from "../../assets/icons/folder.svg?react"; import "./index.css"; @@ -68,13 +69,16 @@ const menu = [ { name: "Team", path: "account/team", icon: }, ], }, -]; - -const other = [ - { name: "Settings", path: "settings", icon: }, - { name: "Support", path: "support", icon: }, - { name: "Docs", path: "docs", icon: }, - { name: "Changelog", path: "changelog", icon: }, + { + name: "Other", + icon: , + nested: [ + { name: "Settings", path: "settings", icon: }, + { name: "Support", path: "support", icon: }, + { name: "Docs", path: "docs", icon: }, + { name: "Changelog", path: "changelog", icon: }, + ], + }, ]; const URL_MAP = { @@ -97,7 +101,7 @@ function Sidebar() { const dispatch = useDispatch(); const authState = useSelector((state) => state.auth); const collapsed = useSelector((state) => state.ui.sidebar.collapsed); - const [open, setOpen] = useState({ Dashboard: false, Account: false }); + const [open, setOpen] = useState({ Dashboard: false, Account: false, Other: false }); const [anchorEl, setAnchorEl] = useState(null); const [popup, setPopup] = useState(); const { user } = useSelector((state) => state.auth); @@ -137,6 +141,8 @@ function Sidebar() { setOpen((prev) => ({ ...prev, Dashboard: true })); else if (location.pathname.includes("/account")) setOpen((prev) => ({ ...prev, Account: true })); + else if (location.pathname.includes("/settings")) + setOpen((prev) => ({ ...prev, Other: true })); }, []); return ( @@ -212,7 +218,7 @@ function Sidebar() { }, }} onClick={() => { - setOpen({ Dashboard: false, Account: false }); + setOpen({ Dashboard: false, Account: false, Other: false }); dispatch(toggleSidebar()); }} > @@ -356,7 +362,12 @@ function Sidebar() { } key={child.path} onClick={() => { - navigate(`/${child.path}`); + const url = URL_MAP[child.path]; + if (url) { + window.open(url, "_blank", "noreferrer"); + } else { + navigate(`/${child.path}`); + } closePopup(); }} sx={{ @@ -382,8 +393,14 @@ function Sidebar() { setOpen((prev) => ({ - ...prev, - [`${item.name}`]: !prev[`${item.name}`], + ...Object.keys(prev).reduce( + (acc, key) => ({ + ...acc, + [key]: false, // close all other sections + }), + {} + ), + [`${item.name}`]: !prev[`${item.name}`], // toggle clicked section })) } sx={{ @@ -419,7 +436,14 @@ function Sidebar() { : "" } key={child.path} - onClick={() => navigate(`/${child.path}`)} + onClick={() => { + const url = URL_MAP[child.path]; + if (url) { + window.open(url, "_blank", "noreferrer"); + } else { + navigate(`/${child.path}`); + } + }} sx={{ gap: theme.spacing(4), borderRadius: theme.shape.borderRadius, @@ -465,69 +489,6 @@ function Sidebar() { ) )} - - {/* other */} - - Other - - } - sx={{ px: theme.spacing(6) }} - > - {other.map((item) => ( - - { - 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, - px: theme.spacing(4), - }} - > - {item.icon} - {item.name} - - - ))} - + + + \ No newline at end of file