"use client"; import { observer } from "mobx-react"; import { useParams, useRouter } from "next/navigation"; import useSWR from "swr"; // components import { EmptyState } from "@/components/common"; import { PageHead } from "@/components/core"; import { ModuleLayoutRoot } from "@/components/issues"; import { ModuleDetailsSidebar } from "@/components/modules"; // hooks import { useModule, useProject } from "@/hooks/store"; import useLocalStorage from "@/hooks/use-local-storage"; // assets import emptyModule from "public/empty-state/module.svg"; const ModuleIssuesPage = observer(() => { // router const router = useRouter(); const { workspaceSlug, projectId, moduleId } = useParams(); // store hooks const { fetchModuleDetails, getModuleById } = useModule(); const { getProjectById } = useProject(); // local storage const { setValue, storedValue } = useLocalStorage("module_sidebar_collapsed", "false"); const isSidebarCollapsed = storedValue ? (storedValue === "true" ? true : false) : false; // fetching module details const { error } = useSWR( workspaceSlug && projectId && moduleId ? `CURRENT_MODULE_DETAILS_${moduleId.toString()}` : null, workspaceSlug && projectId && moduleId ? () => fetchModuleDetails(workspaceSlug.toString(), projectId.toString(), moduleId.toString()) : null ); // derived values const projectModule = moduleId ? getModuleById(moduleId.toString()) : undefined; const project = projectId ? getProjectById(projectId.toString()) : undefined; const pageTitle = project?.name && projectModule?.name ? `${project?.name} - ${projectModule?.name}` : undefined; const toggleSidebar = () => { setValue(`${!isSidebarCollapsed}`); }; if (!workspaceSlug || !projectId || !moduleId) return <>>; return ( <> {error ? ( router.push(`/${workspaceSlug}/projects/${projectId}/modules`), }} /> ) : ( {moduleId && !isSidebarCollapsed && ( )} )} > ); }); export default ModuleIssuesPage;