import { ReactElement, useCallback } from "react"; import { observer } from "mobx-react"; import { useRouter } from "next/router"; import { TModuleFilters } from "@plane/types"; // layouts // components import { PageHead } from "@/components/core"; import { EmptyState } from "@/components/empty-state"; import { ModulesListHeader } from "@/components/headers"; import { ModuleViewHeader, ModuleAppliedFiltersList, ModulesListView } from "@/components/modules"; // types // hooks import ModulesListMobileHeader from "@/components/modules/moduels-list-mobile-header"; import { EmptyStateType } from "@/constants/empty-state"; import { calculateTotalFilters } from "@/helpers/filter.helper"; import { useModuleFilter, useProject } from "@/hooks/store"; import { AppLayout } from "@/layouts/app-layout"; import { NextPageWithLayout } from "@/lib/types"; const ProjectModulesPage: NextPageWithLayout = observer(() => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; // store const { getProjectById, currentProjectDetails } = useProject(); const { currentProjectFilters, currentProjectDisplayFilters, clearAllFilters, updateFilters, updateDisplayFilters } = useModuleFilter(); // derived values const project = projectId ? getProjectById(projectId.toString()) : undefined; const pageTitle = project?.name ? `${project?.name} - Modules` : undefined; const handleRemoveFilter = useCallback( (key: keyof TModuleFilters, value: string | null) => { if (!projectId) return; let newValues = currentProjectFilters?.[key] ?? []; if (!value) newValues = []; else newValues = newValues.filter((val) => val !== value); updateFilters(projectId.toString(), { [key]: newValues }); }, [currentProjectFilters, projectId, updateFilters] ); if (!workspaceSlug || !projectId) return <>>; // No access to if (currentProjectDetails?.module_view === false) return (