plane/apps/space/components/views/project-details.tsx

81 lines
3.0 KiB
TypeScript
Raw Normal View History

2023-08-30 15:03:21 +00:00
import { useEffect } from "react";
2023-08-30 11:21:13 +00:00
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
// components
import { IssueListView } from "components/issues/board-views/list";
import { IssueKanbanView } from "components/issues/board-views/kanban";
import { IssueCalendarView } from "components/issues/board-views/calendar";
import { IssueSpreadsheetView } from "components/issues/board-views/spreadsheet";
import { IssueGanttView } from "components/issues/board-views/gantt";
import { IssuePeekOverview } from "components/issues/peek-overview";
// mobx store
import { RootStore } from "store/root";
import { useMobxStore } from "lib/mobx/store-provider";
2023-08-30 15:03:21 +00:00
export const ProjectDetailsView = observer(() => {
2023-08-30 11:21:13 +00:00
const router = useRouter();
2023-08-30 12:09:11 +00:00
const { workspace_slug, project_slug, states, labels, priorities } = router.query;
2023-08-30 11:21:13 +00:00
2023-08-30 15:03:21 +00:00
const { issue: issueStore, project: projectStore }: RootStore = useMobxStore();
2023-08-30 11:21:13 +00:00
2023-08-30 15:03:21 +00:00
console.log("projectStore?.activeBoard", projectStore?.activeBoard);
const activeIssueId = issueStore.peekId;
2023-08-30 12:09:11 +00:00
useEffect(() => {
if (workspace_slug && project_slug) {
const params = {
state: states || null,
labels: labels || null,
priority: priorities || null,
};
issueStore.fetchPublicIssues(workspace_slug?.toString(), project_slug.toString(), params);
}
}, [workspace_slug, project_slug, issueStore, states, labels, priorities]);
2023-08-30 11:21:13 +00:00
return (
<div className="relative w-full h-full overflow-hidden">
2023-08-30 15:05:10 +00:00
{workspace_slug && (
2023-08-30 11:21:13 +00:00
<IssuePeekOverview
isOpen={Boolean(activeIssueId)}
2023-08-30 15:05:10 +00:00
onClose={() => issueStore.setPeekId(null)}
2023-08-30 12:09:11 +00:00
issue={issueStore?.issues?.find((_issue) => _issue.id === activeIssueId) || null}
2023-08-30 11:21:13 +00:00
workspaceSlug={workspace_slug.toString()}
/>
2023-08-30 15:05:10 +00:00
)}
2023-08-30 11:21:13 +00:00
2023-08-30 12:09:11 +00:00
{issueStore?.loader && !issueStore.issues ? (
2023-08-30 11:21:13 +00:00
<div className="text-sm text-center py-10 text-custom-text-100">Loading...</div>
) : (
<>
2023-08-30 12:09:11 +00:00
{issueStore?.error ? (
2023-08-30 11:21:13 +00:00
<div className="text-sm text-center py-10 bg-custom-background-200 text-custom-text-100">
Something went wrong.
</div>
) : (
2023-08-30 15:03:21 +00:00
projectStore?.activeBoard && (
2023-08-30 11:21:13 +00:00
<>
2023-08-30 15:03:21 +00:00
{projectStore?.activeBoard === "list" && (
2023-08-30 11:21:13 +00:00
<div className="relative w-full h-full overflow-y-auto">
<div className="mx-auto px-4">
<IssueListView />
</div>
</div>
)}
2023-08-30 15:03:21 +00:00
{projectStore?.activeBoard === "kanban" && (
2023-08-30 11:21:13 +00:00
<div className="relative w-full h-full mx-auto px-9 py-5">
<IssueKanbanView />
</div>
)}
2023-08-30 15:03:21 +00:00
{projectStore?.activeBoard === "calendar" && <IssueCalendarView />}
{projectStore?.activeBoard === "spreadsheet" && <IssueSpreadsheetView />}
{projectStore?.activeBoard === "gantt" && <IssueGanttView />}
2023-08-30 11:21:13 +00:00
</>
)
)}
</>
)}
</div>
);
2023-08-30 15:03:21 +00:00
});