/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { useEffect, useState } from "react"; import { observer } from "mobx-react"; import { PanelLeft } from "lucide-react"; import { useTranslation } from "@plane/i18n"; import { TransferIcon } from "@plane/propel/icons"; import type { TInboxIssueCurrentTab } from "@plane/types"; import { EInboxIssueCurrentTab } from "@plane/types"; import { cn } from "@plane/utils"; import { useProjectExternalContours } from "@/hooks/store/use-project-external-contours"; import { ExternalContoursContentRoot } from "./content-root"; import { ExternalContoursEmptyState } from "./empty-state"; import { ExternalContoursSidebar } from "./sidebar"; type TExternalContoursRoot = { workspaceSlug: string; projectId: string; inboxIssueId: string | undefined; navigationTab?: TInboxIssueCurrentTab | undefined; }; export const ExternalContoursRoot = observer(function ExternalContoursRoot(props: TExternalContoursRoot) { const { workspaceSlug, projectId, inboxIssueId, navigationTab } = props; const [isMobileSidebar, setIsMobileSidebar] = useState(true); const { t } = useTranslation(); const { loader, error, currentTab, currentProjectId, requestIds, handleCurrentTab, fetchRequests } = useProjectExternalContours(); useEffect(() => { if (!workspaceSlug || !projectId) return; const resolvedTab = navigationTab || EInboxIssueCurrentTab.OPEN; const hasProjectChanged = currentProjectId && currentProjectId !== projectId; if (hasProjectChanged) { void handleCurrentTab(workspaceSlug, projectId, EInboxIssueCurrentTab.OPEN); return; } if (currentProjectId === projectId && currentTab === resolvedTab) { if (loader === "init-loading") return; if (requestIds.length > 0) return; } if (currentTab !== resolvedTab) { void handleCurrentTab(workspaceSlug, projectId, resolvedTab); return; } void fetchRequests(workspaceSlug.toString(), projectId.toString(), resolvedTab); // eslint-disable-next-line react-hooks/exhaustive-deps }, [workspaceSlug, projectId, navigationTab]); if (error && error?.status === "init-error") { return (
{error?.message}
); } return ( <> {!inboxIssueId && (
setIsMobileSidebar(!isMobileSidebar)} className={cn("h-4 w-4", isMobileSidebar ? "text-accent-primary" : "text-secondary")} />
)}
{inboxIssueId ? ( ) : (
)}
); });