import { FC } from "react"; import { observer } from "mobx-react"; import useSWR from "swr"; import { Inbox } 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"; // hooks import { useProjectInbox } from "@/hooks/store"; type TInboxIssueRoot = { workspaceSlug: string; projectId: string; inboxIssueId: string | undefined; inboxAccessible: boolean; }; export const InboxIssueRoot: FC = observer((props) => { const { workspaceSlug, projectId, inboxIssueId, inboxAccessible } = props; // hooks const { loader, error, fetchInboxIssues } = useProjectInbox(); useSWR( inboxAccessible && workspaceSlug && projectId ? `PROJECT_INBOX_ISSUES_${workspaceSlug}_${projectId}` : null, async () => { inboxAccessible && workspaceSlug && projectId && (await fetchInboxIssues(workspaceSlug.toString(), projectId.toString())); }, { revalidateOnFocus: false, revalidateIfStale: false } ); // loader if (loader === "init-loading") return (
); // error if (error && error?.status === "init-error") return (
{error?.message}
); return (
{inboxIssueId ? ( ) : (
)}
); });