import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; // constants import { issueViews } from "constants/data"; // mobx import { useMobxStore } from "lib/mobx/store-provider"; import { RootStore } from "store/root"; 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}
); } })} ); });