2023-01-26 18:12:20 +00:00
|
|
|
import React from "react";
|
2023-05-11 12:08:46 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
import Link from "next/link";
|
2023-07-18 06:37:55 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-05-11 12:08:46 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
// hooks
|
|
|
|
import useTheme from "hooks/use-theme";
|
2023-07-18 06:37:55 +00:00
|
|
|
|
|
|
|
import { NotificationPopover } from "components/notifications";
|
|
|
|
|
|
|
|
const workspaceLinks = (workspaceSlug: string) => [
|
|
|
|
{
|
|
|
|
icon: "grid_view",
|
|
|
|
name: "Dashboard",
|
|
|
|
href: `/${workspaceSlug}`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: "bar_chart",
|
|
|
|
name: "Analytics",
|
|
|
|
href: `/${workspaceSlug}/analytics`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: "work",
|
|
|
|
name: "Projects",
|
|
|
|
href: `/${workspaceSlug}/projects`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: "task_alt",
|
|
|
|
name: "My Issues",
|
|
|
|
href: `/${workspaceSlug}/me/my-issues`,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-07-13 13:05:43 +00:00
|
|
|
// components
|
|
|
|
import { Icon, Tooltip } from "components/ui";
|
2023-01-26 18:12:20 +00:00
|
|
|
|
2023-05-16 05:11:37 +00:00
|
|
|
export const WorkspaceSidebarMenu = () => {
|
2023-01-26 18:12:20 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query;
|
2023-05-11 12:08:46 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
// theme context
|
|
|
|
const { collapsed: sidebarCollapse } = useTheme();
|
|
|
|
|
|
|
|
return (
|
2023-07-13 13:05:43 +00:00
|
|
|
<div className="w-full cursor-pointer space-y-2 px-4 mt-5">
|
2023-07-10 07:17:00 +00:00
|
|
|
{workspaceLinks(workspaceSlug as string).map((link, index) => {
|
|
|
|
const isActive =
|
|
|
|
link.name === "Settings"
|
|
|
|
? router.asPath.includes(link.href)
|
|
|
|
: router.asPath === link.href;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Link key={index} href={link.href}>
|
2023-07-13 13:05:43 +00:00
|
|
|
<a className="block w-full">
|
|
|
|
<Tooltip
|
|
|
|
tooltipContent={link.name}
|
|
|
|
position="right"
|
|
|
|
className="ml-2"
|
|
|
|
disabled={!sidebarCollapse}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${
|
2023-07-10 07:17:00 +00:00
|
|
|
isActive
|
2023-07-13 13:05:43 +00:00
|
|
|
? "bg-custom-primary-100/10 text-custom-primary-100"
|
|
|
|
: "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80"
|
|
|
|
} ${sidebarCollapse ? "justify-center" : ""}`}
|
|
|
|
>
|
|
|
|
<Icon iconName={`${link.icon}`} />
|
|
|
|
{!sidebarCollapse && link.name}
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
2023-07-10 07:17:00 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
})}
|
2023-07-18 06:37:55 +00:00
|
|
|
|
|
|
|
<NotificationPopover />
|
2023-01-26 18:12:20 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|