import { Brush2, DocumentText, Home2, Logout } from "iconsax-react"; import { type FC, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useLocation } from "react-router-dom"; import LogoSmall from "../assets/images/logo-small.svg"; import LogoImage from "../assets/images/logo.svg"; import { Paths } from "../config/Paths"; import { clx } from "../helpers/utils"; import BuyCatalog from "./components/BuyCatalog"; import SideBarItem from "./SideBarItem"; import { useSharedStore } from "./store/sharedStore"; const SideBar: FC = () => { const { t } = useTranslation("global"); const { openSidebar, setOpenSidebar, hasSubMenu, setSubMenuName, setSubtMenu, subMenuName } = useSharedStore(); const location = useLocation(); const isActive = (path: string) => { const pathname = location.pathname; if (path === "/") return pathname === "/"; return pathname === path || pathname.startsWith(path + "/"); }; useEffect(() => { const split = location.pathname.split("/"); if (split[1] === "dashboard" || split[1] === "products") { setSubMenuName(split[1]); setSubtMenu(true); } else { setSubMenuName(""); setSubtMenu(false); } }, [location.pathname, setSubMenuName, setSubtMenu]); const iconSizeSideBar = 20; return ( <> {openSidebar &&
setOpenSidebar(false)} />}
{!hasSubMenu ? : }
{t("sidebar.menu")}
} title={t("sidebar.home_page")} isActive={isActive(Paths.home)} link={Paths.home} activeName={Paths.home} /> } title={t("sidebar.catalog")} isActive={isActive(Paths.catalog.list)} link={Paths.catalog.list} activeName={Paths.catalog.list} /> } title={t("sidebar.request_design")} isActive={isActive(Paths.designer.list)} link={Paths.designer.list} activeName={Paths.designer.list} />
} title="خروج" isActive={isActive("logout")} link={`#`} isLogout activeName="" />
{/* منوی فرعی */} {hasSubMenu && (openSidebar || window.innerWidth > 1139) && (
{subMenuName === "dashboard" ? null : // null}
)} ); }; export default SideBar;