fix: module empty state (#4004)

This commit is contained in:
Anmol Singh Bhatia 2024-03-20 20:00:13 +05:30 committed by GitHub
parent 180f1d74e8
commit 054dd2bb7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@ import { CycleModuleBoardLayout, CycleModuleListLayout, GanttLayoutLoader } from
// assets // assets
// constants // constants
import { EmptyStateType } from "@/constants/empty-state"; import { EmptyStateType } from "@/constants/empty-state";
import { calculateTotalFilters } from "@/helpers/filter.helper";
import { useApplication, useEventTracker, useModule, useModuleFilter } from "@/hooks/store"; import { useApplication, useEventTracker, useModule, useModuleFilter } from "@/hooks/store";
import AllFiltersImage from "public/empty-state/module/all-filters.svg"; import AllFiltersImage from "public/empty-state/module/all-filters.svg";
import NameFilterImage from "public/empty-state/module/name-filter.svg"; import NameFilterImage from "public/empty-state/module/name-filter.svg";
@ -22,10 +23,12 @@ export const ModulesListView: React.FC = observer(() => {
const { commandPalette: commandPaletteStore } = useApplication(); const { commandPalette: commandPaletteStore } = useApplication();
const { setTrackElement } = useEventTracker(); const { setTrackElement } = useEventTracker();
const { getFilteredModuleIds, loader } = useModule(); const { getFilteredModuleIds, loader } = useModule();
const { currentProjectDisplayFilters: displayFilters, searchQuery } = useModuleFilter(); const { currentProjectDisplayFilters: displayFilters, searchQuery, currentProjectFilters } = useModuleFilter();
// derived values // derived values
const filteredModuleIds = projectId ? getFilteredModuleIds(projectId.toString()) : undefined; const filteredModuleIds = projectId ? getFilteredModuleIds(projectId.toString()) : undefined;
const totalFilters = calculateTotalFilters(currentProjectFilters ?? {});
if (loader || !filteredModuleIds) if (loader || !filteredModuleIds)
return ( return (
<> <>
@ -35,7 +38,7 @@ export const ModulesListView: React.FC = observer(() => {
</> </>
); );
if (filteredModuleIds.length === 0) if (totalFilters > 0 || searchQuery.trim() !== "")
return ( return (
<div className="h-full w-full grid place-items-center"> <div className="h-full w-full grid place-items-center">
<div className="text-center"> <div className="text-center">