import { useEffect } from "react"; import Image from "next/image"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; // components import { NavbarSearch } from "./search"; import { NavbarIssueBoardView } from "./issue-board-view"; import { NavbarIssueFilter } from "./issue-filter"; import { NavbarTheme } from "./theme"; // lib import { useMobxStore } from "lib/mobx/store-provider"; // store import { RootStore } from "store/root"; const renderEmoji = (emoji: string | { name: string; color: string }) => { if (!emoji) return; if (typeof emoji === "object") return ( {emoji.name} ); else return isNaN(parseInt(emoji)) ? emoji : String.fromCodePoint(parseInt(emoji)); }; const IssueNavbar = observer(() => { const { project: projectStore }: RootStore = useMobxStore(); // router const router = useRouter(); const { workspace_slug, project_slug, board } = router.query; useEffect(() => { if (workspace_slug && project_slug) { projectStore.fetchProjectSettings(workspace_slug.toString(), project_slug.toString()); } }, [projectStore, workspace_slug, project_slug]); useEffect(() => { if (workspace_slug && projectStore) { if (board) { projectStore.setActiveBoard(board.toString()); } else { router.push(`/${workspace_slug}/${project_slug}?board=list`); projectStore.setActiveBoard("list"); } } }, [board, router, projectStore, workspace_slug, project_slug]); return (
{/* project detail */}
{projectStore?.project && projectStore?.project?.emoji ? ( renderEmoji(projectStore?.project?.emoji) ) : ( plane logo )}
{projectStore?.project?.name || `...`}
{/* issue search bar */}
{/* issue views */}
{/* theming */}
); }); export default IssueNavbar;