import { FC, useEffect, useState } from "react"; import { observer } from "mobx-react"; import { PanelLeft } from "lucide-react"; // plane imports import { useTranslation } from "@plane/i18n"; import { Intake } from "@plane/propel/icons"; import { EInboxIssueCurrentTab } from "@plane/types"; import { cn } from "@plane/utils"; // components import { SimpleEmptyState } from "@/components/empty-state/simple-empty-state-root"; import { InboxContentRoot } from "@/components/inbox/content"; import { InboxSidebar } from "@/components/inbox/sidebar"; import { InboxLayoutLoader } from "@/components/ui/loader/layouts/project-inbox/inbox-layout-loader"; // hooks import { useProjectInbox } from "@/hooks/store/use-project-inbox"; import { useResolvedAssetPath } from "@/hooks/use-resolved-asset-path"; type TInboxIssueRoot = { workspaceSlug: string; projectId: string; inboxIssueId: string | undefined; inboxAccessible: boolean; navigationTab?: EInboxIssueCurrentTab | undefined; }; export const InboxIssueRoot: FC = observer((props) => { const { workspaceSlug, projectId, inboxIssueId, inboxAccessible, navigationTab } = props; // states const [isMobileSidebar, setIsMobileSidebar] = useState(true); // plane hooks const { t } = useTranslation(); // hooks const { loader, error, currentTab, handleCurrentTab, fetchInboxIssues } = useProjectInbox(); // derived values const resolvedPath = useResolvedAssetPath({ basePath: "/empty-state/intake/issue-detail" }); useEffect(() => { if (!inboxAccessible || !workspaceSlug || !projectId) return; if (navigationTab && navigationTab !== currentTab) { handleCurrentTab(workspaceSlug, projectId, navigationTab); } else { fetchInboxIssues( workspaceSlug.toString(), projectId.toString(), undefined, navigationTab || EInboxIssueCurrentTab.OPEN ); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [inboxAccessible, workspaceSlug, projectId]); // loader if (loader === "init-loading") return (
); // error if (error && error?.status === "init-error") return (
{error?.message}
); return ( <> {!inboxIssueId && (
setIsMobileSidebar(!isMobileSidebar)} className={cn("w-4 h-4 ", isMobileSidebar ? "text-custom-primary-100" : " text-custom-text-200")} />
)}
{inboxIssueId ? ( ) : (
)}
); });