import { ReactElement } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // hooks import { useModule } from "hooks/store"; import useLocalStorage from "hooks/use-local-storage"; // layouts import { AppLayout } from "layouts/app-layout"; // components import { ModuleDetailsSidebar } from "components/modules"; import { ModuleLayoutRoot } from "components/issues"; import { ModuleIssuesHeader } from "components/headers"; // ui import { EmptyState } from "components/common"; // assets import emptyModule from "public/empty-state/module.svg"; // types import { NextPageWithLayout } from "lib/types"; const ModuleIssuesPage: NextPageWithLayout = () => { // router const router = useRouter(); const { workspaceSlug, projectId, moduleId } = router.query; // store hooks const { fetchModuleDetails } = useModule(); // local storage const { setValue, storedValue } = useLocalStorage("module_sidebar_collapsed", "false"); const isSidebarCollapsed = storedValue ? (storedValue === "true" ? true : false) : false; const { error } = useSWR( workspaceSlug && projectId && moduleId ? `CURRENT_MODULE_DETAILS_${moduleId.toString()}` : null, workspaceSlug && projectId && moduleId ? () => fetchModuleDetails(workspaceSlug.toString(), projectId.toString(), moduleId.toString()) : null ); const toggleSidebar = () => { setValue(`${!isSidebarCollapsed}`); }; return ( <> {error ? ( router.push(`/${workspaceSlug}/projects/${projectId}/modules`), }} /> ) : (
{moduleId && !isSidebarCollapsed && (
)}
)} ); }; ModuleIssuesPage.getLayout = function getLayout(page: ReactElement) { return ( } withProjectWrapper> {page} ); }; export default ModuleIssuesPage;