2024-04-10 10:38:31 +00:00
|
|
|
import { ReactElement, useEffect } from "react";
|
2024-03-06 13:09:14 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-01-24 15:03:54 +00:00
|
|
|
import { useRouter } from "next/router";
|
2024-04-08 13:41:47 +00:00
|
|
|
// components
|
|
|
|
import { PageHead } from "@/components/core";
|
|
|
|
import { EmptyState } from "@/components/empty-state";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { ProjectInboxHeader } from "@/components/headers";
|
2024-04-08 13:41:47 +00:00
|
|
|
import { InboxIssueRoot } from "@/components/inbox";
|
|
|
|
// constants
|
|
|
|
import { EmptyStateType } from "@/constants/empty-state";
|
2024-04-10 14:25:16 +00:00
|
|
|
// helpers
|
|
|
|
import { EInboxIssueCurrentTab } from "@/helpers/inbox.helper";
|
2024-04-08 13:41:47 +00:00
|
|
|
// hooks
|
2024-04-10 10:38:31 +00:00
|
|
|
import { useProject, useProjectInbox } from "@/hooks/store";
|
2024-01-24 15:03:54 +00:00
|
|
|
// layouts
|
2024-03-19 14:38:35 +00:00
|
|
|
import { AppLayout } from "@/layouts/app-layout";
|
2024-01-24 15:03:54 +00:00
|
|
|
// types
|
2024-03-19 14:38:35 +00:00
|
|
|
import { NextPageWithLayout } from "@/lib/types";
|
2024-01-24 15:03:54 +00:00
|
|
|
|
|
|
|
const ProjectInboxPage: NextPageWithLayout = observer(() => {
|
2024-04-08 13:41:47 +00:00
|
|
|
/// router
|
2024-01-24 15:03:54 +00:00
|
|
|
const router = useRouter();
|
2024-04-10 10:38:31 +00:00
|
|
|
const { workspaceSlug, projectId, currentTab: navigationTab, inboxIssueId } = router.query;
|
2024-04-08 13:41:47 +00:00
|
|
|
// hooks
|
2024-01-24 15:03:54 +00:00
|
|
|
const { currentProjectDetails } = useProject();
|
2024-04-10 10:38:31 +00:00
|
|
|
const { currentTab, handleCurrentTab } = useProjectInbox();
|
2024-01-24 15:03:54 +00:00
|
|
|
|
2024-04-08 13:41:47 +00:00
|
|
|
if (!workspaceSlug || !projectId) return <></>;
|
|
|
|
|
|
|
|
// No access to inbox
|
|
|
|
if (currentProjectDetails?.inbox_view === false)
|
|
|
|
return (
|
|
|
|
<div className="flex items-center justify-center h-full w-full">
|
|
|
|
<EmptyState
|
|
|
|
type={EmptyStateType.DISABLED_PROJECT_INBOX}
|
|
|
|
primaryButtonLink={`/${workspaceSlug}/projects/${projectId}/settings/features`}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
// derived values
|
|
|
|
const pageTitle = currentProjectDetails?.name ? `${currentProjectDetails?.name} - Inbox` : "Plane - Inbox";
|
2024-01-24 15:03:54 +00:00
|
|
|
|
2024-04-10 10:38:31 +00:00
|
|
|
useEffect(() => {
|
2024-04-10 14:25:16 +00:00
|
|
|
if (navigationTab && currentTab != navigationTab)
|
|
|
|
handleCurrentTab(navigationTab === "open" ? EInboxIssueCurrentTab.OPEN : EInboxIssueCurrentTab.CLOSED);
|
2024-04-10 10:38:31 +00:00
|
|
|
}, [currentTab, navigationTab, handleCurrentTab]);
|
|
|
|
|
2024-01-24 15:03:54 +00:00
|
|
|
return (
|
|
|
|
<div className="flex h-full flex-col">
|
2024-04-08 13:41:47 +00:00
|
|
|
<PageHead title={pageTitle} />
|
|
|
|
<div className="w-full h-full overflow-hidden">
|
|
|
|
<InboxIssueRoot
|
|
|
|
workspaceSlug={workspaceSlug.toString()}
|
|
|
|
projectId={projectId.toString()}
|
|
|
|
inboxIssueId={inboxIssueId?.toString() || undefined}
|
|
|
|
inboxAccessible={currentProjectDetails?.inbox_view || false}
|
|
|
|
/>
|
|
|
|
</div>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
ProjectInboxPage.getLayout = function getLayout(page: ReactElement) {
|
|
|
|
return (
|
|
|
|
<AppLayout header={<ProjectInboxHeader />} withProjectWrapper>
|
|
|
|
{page}
|
|
|
|
</AppLayout>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ProjectInboxPage;
|