import React from "react"; import { useRouter } from "next/router"; import Link from "next/link"; // hooks import useTheme from "hooks/use-theme"; // icons import { GridViewIcon, AssignmentClipboardIcon, TickMarkIcon, SettingIcon } from "components/icons"; import { ChartBarIcon } from "@heroicons/react/24/outline"; type Props = { isAnalyticsModalOpen: boolean; setAnalyticsModal: React.Dispatch>; }; export const WorkspaceSidebarMenu: React.FC = ({ isAnalyticsModalOpen, setAnalyticsModal, }) => { const router = useRouter(); const { workspaceSlug } = router.query; // theme context const { collapsed: sidebarCollapse } = useTheme(); const workspaceLinks = (workspaceSlug: string) => [ { icon: GridViewIcon, name: "Dashboard", href: `/${workspaceSlug}`, }, { icon: ChartBarIcon, name: "Analytics", highlight: isAnalyticsModalOpen, onClick: () => setAnalyticsModal((prevData) => !prevData), }, { icon: AssignmentClipboardIcon, name: "Projects", href: `/${workspaceSlug}/projects`, }, { icon: TickMarkIcon, name: "My Issues", href: `/${workspaceSlug}/me/my-issues`, }, { icon: SettingIcon, name: "Settings", href: `/${workspaceSlug}/settings`, }, ]; return (
{workspaceLinks(workspaceSlug as string).map((link, index) => { if (link.href) return ( {!sidebarCollapse && link.name} ); else return ( ); })}
); };