import { FC, useEffect, useState } from "react"; import { observer } from "mobx-react"; import { Inbox, PanelLeft } from "lucide-react"; // components import { EmptyState } from "@/components/empty-state"; import { InboxSidebar, InboxContentRoot } from "@/components/inbox"; import { InboxLayoutLoader } from "@/components/ui"; // constants import { EmptyStateType } from "@/constants/empty-state"; // helpers import { cn } from "@/helpers/common.helper"; import { EInboxIssueCurrentTab } from "@/helpers/inbox.helper"; // hooks import { useProjectInbox } from "@/hooks/store"; 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); // hooks const { loader, error, currentTab, handleCurrentTab, fetchInboxIssues } = useProjectInbox(); useEffect(() => { if (!inboxAccessible || !workspaceSlug || !projectId) return; if (navigationTab && navigationTab !== currentTab) { handleCurrentTab(navigationTab); } else { fetchInboxIssues(workspaceSlug.toString(), projectId.toString()); } // 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 ? ( ) : (
)}
); });