2023-10-18 13:47:02 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import Link from "next/link";
|
2023-11-28 11:35:42 +00:00
|
|
|
// mobx store
|
2023-11-15 10:26:57 +00:00
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-11-28 11:35:42 +00:00
|
|
|
// constants
|
|
|
|
import { EUserWorkspaceRoles, WORKSPACE_SETTINGS_LINKS } from "constants/workspace";
|
2023-10-18 13:47:02 +00:00
|
|
|
|
|
|
|
export const WorkspaceSettingsSidebar = () => {
|
2023-11-28 11:35:42 +00:00
|
|
|
// router
|
2023-10-18 13:47:02 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query;
|
2023-11-28 11:35:42 +00:00
|
|
|
// mobx store
|
|
|
|
const {
|
|
|
|
user: { currentWorkspaceRole },
|
|
|
|
} = useMobxStore();
|
2023-10-18 13:47:02 +00:00
|
|
|
|
2023-11-28 11:35:42 +00:00
|
|
|
const workspaceMemberInfo = currentWorkspaceRole || EUserWorkspaceRoles.GUEST;
|
2023-10-18 13:47:02 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="flex flex-col gap-6 w-80 px-5">
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
<span className="text-xs text-custom-sidebar-text-400 font-semibold">SETTINGS</span>
|
|
|
|
<div className="flex flex-col gap-1 w-full">
|
2023-11-28 11:35:42 +00:00
|
|
|
{WORKSPACE_SETTINGS_LINKS.map(
|
2023-11-15 10:26:57 +00:00
|
|
|
(link) =>
|
|
|
|
workspaceMemberInfo >= link.access && (
|
2023-11-28 11:35:42 +00:00
|
|
|
<Link key={link.href} href={`/${workspaceSlug}/${link.href}`}>
|
2023-11-29 15:02:10 +00:00
|
|
|
<span>
|
2023-11-15 10:26:57 +00:00
|
|
|
<div
|
|
|
|
className={`px-4 py-2 text-sm font-medium rounded-md ${
|
2023-11-28 11:35:42 +00:00
|
|
|
router.pathname.split("/")?.[3] === link.href.split("/")?.[2]
|
2023-11-15 10:26:57 +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"
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
{link.label}
|
|
|
|
</div>
|
2023-11-29 15:02:10 +00:00
|
|
|
</span>
|
2023-11-15 10:26:57 +00:00
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
)}
|
2023-10-18 13:47:02 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|