2023-11-27 08:45:33 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
import useSWR from "swr";
|
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
import { DraftIssueAppliedFiltersRoot } from "../filters/applied-filters/roots/draft-issue";
|
|
|
|
import { DraftIssueListLayout } from "../list/roots/draft-issue-root";
|
|
|
|
import { Spinner } from "@plane/ui";
|
|
|
|
import { DraftKanBanLayout } from "../kanban/roots/draft-issue-root";
|
|
|
|
|
|
|
|
export const DraftIssueLayoutRoot: React.FC = observer(() => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string };
|
|
|
|
|
|
|
|
const {
|
|
|
|
projectDraftIssuesFilter: { issueFilters, fetchFilters },
|
|
|
|
projectDraftIssues: { loader, getIssues, fetchIssues },
|
|
|
|
} = useMobxStore();
|
|
|
|
|
|
|
|
useSWR(workspaceSlug && projectId ? `DRAFT_FILTERS_AND_ISSUES_${projectId.toString()}` : null, async () => {
|
|
|
|
if (workspaceSlug && projectId) {
|
|
|
|
await fetchFilters(workspaceSlug, projectId);
|
|
|
|
await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const activeLayout = issueFilters?.displayFilters?.layout || undefined;
|
|
|
|
|
|
|
|
return (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="relative flex h-full w-full flex-col overflow-hidden">
|
2023-11-27 08:45:33 +00:00
|
|
|
<DraftIssueAppliedFiltersRoot />
|
|
|
|
|
|
|
|
{loader === "init-loader" ? (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex h-full w-full items-center justify-center">
|
2023-11-27 08:45:33 +00:00
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="relative h-full w-full overflow-auto">
|
2023-11-27 08:45:33 +00:00
|
|
|
{activeLayout === "list" ? (
|
|
|
|
<DraftIssueListLayout />
|
|
|
|
) : activeLayout === "kanban" ? (
|
|
|
|
<DraftKanBanLayout />
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|