2023-09-29 09:30:51 +00:00
|
|
|
import React from "react";
|
2023-07-26 12:21:26 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-09-29 09:30:51 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2023-07-26 12:21:26 +00:00
|
|
|
import useSWR from "swr";
|
|
|
|
|
2023-09-29 09:30:51 +00:00
|
|
|
// mobx store
|
2023-09-26 07:48:42 +00:00
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-09-29 09:30:51 +00:00
|
|
|
// components
|
2023-10-02 07:11:40 +00:00
|
|
|
import { AppliedFiltersList, CalendarLayout, GanttLayout, KanBanLayout, SpreadsheetLayout } from "components/issues";
|
2023-07-26 12:21:26 +00:00
|
|
|
|
2023-09-29 09:30:51 +00:00
|
|
|
export const AllViews: React.FC = observer(() => {
|
2023-07-26 12:21:26 +00:00
|
|
|
const router = useRouter();
|
2023-09-29 09:30:51 +00:00
|
|
|
const { workspaceSlug, projectId } = router.query as {
|
2023-09-26 07:48:42 +00:00
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
cycleId: string;
|
|
|
|
moduleId: string;
|
|
|
|
};
|
2023-07-26 12:21:26 +00:00
|
|
|
|
2023-09-28 09:46:24 +00:00
|
|
|
const { issue: issueStore, project: projectStore, issueFilter: issueFilterStore } = useMobxStore();
|
2023-07-26 12:21:26 +00:00
|
|
|
|
2023-09-26 07:48:42 +00:00
|
|
|
useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES` : null, async () => {
|
|
|
|
if (workspaceSlug && projectId) {
|
|
|
|
await issueFilterStore.fetchUserProjectFilters(workspaceSlug, projectId);
|
|
|
|
|
|
|
|
await projectStore.fetchProjectStates(workspaceSlug, projectId);
|
|
|
|
await projectStore.fetchProjectLabels(workspaceSlug, projectId);
|
|
|
|
await projectStore.fetchProjectMembers(workspaceSlug, projectId);
|
|
|
|
|
|
|
|
await issueStore.fetchIssues(workspaceSlug, projectId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-09-28 09:46:24 +00:00
|
|
|
const activeLayout = issueFilterStore.userDisplayFilters.layout;
|
|
|
|
|
2023-07-26 12:21:26 +00:00
|
|
|
return (
|
2023-10-02 07:11:40 +00:00
|
|
|
<div className="relative w-full h-full flex flex-col overflow-auto">
|
|
|
|
<AppliedFiltersList />
|
2023-09-29 09:30:51 +00:00
|
|
|
{activeLayout === "kanban" ? (
|
|
|
|
<KanBanLayout />
|
|
|
|
) : activeLayout === "calendar" ? (
|
|
|
|
<CalendarLayout />
|
|
|
|
) : activeLayout === "gantt_chart" ? (
|
|
|
|
<GanttLayout />
|
2023-09-29 10:44:47 +00:00
|
|
|
) : activeLayout === "spreadsheet" ? (
|
|
|
|
<SpreadsheetLayout />
|
2023-09-29 09:30:51 +00:00
|
|
|
) : null}
|
2023-09-26 07:48:42 +00:00
|
|
|
</div>
|
2023-07-26 12:21:26 +00:00
|
|
|
);
|
2023-09-28 09:46:24 +00:00
|
|
|
});
|