import { observer } from "mobx-react-lite"; import Image from "next/image"; import { useRouter } from "next/router"; // hooks // components import { EmptyState } from "@/components/empty-state"; import { ModuleCardItem, ModuleListItem, ModulePeekOverview, ModulesListGanttChartView } from "@/components/modules"; // ui import { CycleModuleBoardLayout, CycleModuleListLayout, GanttLayoutLoader } from "@/components/ui"; // assets // constants import { EmptyStateType } from "@/constants/empty-state"; import { calculateTotalFilters } from "@/helpers/filter.helper"; import { useApplication, useEventTracker, useModule, useModuleFilter } from "@/hooks/store"; import AllFiltersImage from "public/empty-state/module/all-filters.svg"; import NameFilterImage from "public/empty-state/module/name-filter.svg"; export const ModulesListView: React.FC = observer(() => { // router const router = useRouter(); const { workspaceSlug, projectId, peekModule } = router.query; // store hooks const { commandPalette: commandPaletteStore } = useApplication(); const { setTrackElement } = useEventTracker(); const { getFilteredModuleIds, loader } = useModule(); const { currentProjectDisplayFilters: displayFilters, searchQuery, currentProjectFilters } = useModuleFilter(); // derived values const filteredModuleIds = projectId ? getFilteredModuleIds(projectId.toString()) : undefined; const totalFilters = calculateTotalFilters(currentProjectFilters ?? {}); if (loader || !filteredModuleIds) return ( <> {displayFilters?.layout === "list" && } {displayFilters?.layout === "board" && } {displayFilters?.layout === "gantt" && } ); if (totalFilters > 0 || searchQuery.trim() !== "") return (
No matching modules
No matching modules

{searchQuery.trim() === "" ? "Remove the filters to see all modules" : "Remove the search criteria to see all modules"}

); return ( <> {filteredModuleIds.length > 0 ? ( <> {displayFilters?.layout === "list" && (
{filteredModuleIds.map((moduleId) => ( ))}
)} {displayFilters?.layout === "board" && (
{filteredModuleIds.map((moduleId) => ( ))}
)} {displayFilters?.layout === "gantt" && } ) : ( { setTrackElement("Module empty state"); commandPaletteStore.toggleCreateModuleModal(true); }} /> )} ); });