import React from "react"
import { observer } from "mobx-react";
import { useParams } from "next/navigation";
import useSWR from "swr";
// mobx store
// components
import {
IssuePeekOverview,
ModuleAppliedFiltersRoot,
ModuleCalendarLayout,
BaseGanttRoot,
ModuleKanBanLayout,
ModuleListLayout,
ModuleSpreadsheetLayout,
} from "@/components/issues";
// constants
import { EIssueLayoutTypes, EIssuesStoreType } from "@/constants/issue";
import { useIssues } from "@/hooks/store";
import { IssuesStoreContext } from "@/hooks/use-issue-layout-store";
// types
const ModuleIssueLayout = (props: { activeLayout: EIssueLayoutTypes | undefined; moduleId: string }) => {
switch (props.activeLayout) {
case EIssueLayoutTypes.LIST:
return ;
case EIssueLayoutTypes.KANBAN:
return ;
case EIssueLayoutTypes.CALENDAR:
return ;
case EIssueLayoutTypes.GANTT:
return ;
case EIssueLayoutTypes.SPREADSHEET:
return ;
default:
return null;
}
};
export const ModuleLayoutRoot: React.FC = observer(() => {
// router
const { workspaceSlug, projectId, moduleId } = useParams();
// hooks
const { issuesFilter } = useIssues(EIssuesStoreType.MODULE);
useSWR(
workspaceSlug && projectId && moduleId
? `MODULE_ISSUES_${workspaceSlug.toString()}_${projectId.toString()}_${moduleId.toString()}`
: null,
async () => {
if (workspaceSlug && projectId && moduleId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString());
}
},
{ revalidateIfStale: false, revalidateOnFocus: false }
);
if (!workspaceSlug || !projectId || !moduleId) return <>>;
const activeLayout = issuesFilter?.issueFilters?.displayFilters?.layout || undefined;
return (
);
});