import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; // constants import { issueViews } from "@/constants/data"; // mobx import { useMobxStore } from "@/hooks/store"; import { RootStore } from "@/store/root.store"; import { TIssueBoardKeys } from "types/issue"; export const NavbarIssueBoardView = observer(() => { const { project: { viewOptions, setActiveBoard, activeBoard }, }: RootStore = useMobxStore(); // router const router = useRouter(); const { workspace_slug, project_slug } = router.query as { workspace_slug: string; project_slug: string }; const handleCurrentBoardView = (boardView: string) => { setActiveBoard(boardView as TIssueBoardKeys); router.push(`/${workspace_slug}/${project_slug}?board=${boardView}`); }; return ( <> {viewOptions && Object.keys(viewOptions).map((viewKey: string) => { if (viewOptions[viewKey]) { return (
handleCurrentBoardView(viewKey)} title={viewKey} > {issueViews[viewKey]?.icon}
); } })} ); });