import { useCallback } from "react"; import { observer } from "mobx-react"; import { ListFilter } from "lucide-react"; import { TPageFilterProps, TPageNavigationTabs } from "@plane/types"; // components import { FiltersDropdown } from "@/components/issues"; import { PageAppliedFiltersList, PageFiltersSelection, PageOrderByDropdown, PageSearchInput, PageTabNavigation, } from "@/components/pages"; // helpers import { calculateTotalFilters } from "@/helpers/filter.helper"; // hooks import { useMember, useProjectPages } from "@/hooks/store"; type Props = { pageType: TPageNavigationTabs; projectId: string; workspaceSlug: string; }; export const PagesListHeaderRoot: React.FC = observer((props) => { const { pageType, projectId, workspaceSlug } = props; // store hooks const { filters, updateFilters, clearAllFilters } = useProjectPages(projectId); const { workspace: { workspaceMemberIds }, } = useMember(); const handleRemoveFilter = useCallback( (key: keyof TPageFilterProps, value: string | null) => { let newValues = filters.filters?.[key]; if (key === "favorites") newValues = !!value; if (Array.isArray(newValues)) { if (!value) newValues = []; else newValues = newValues.filter((val) => val !== value); } updateFilters("filters", { [key]: newValues }); }, [filters.filters, updateFilters] ); const isFiltersApplied = calculateTotalFilters(filters?.filters ?? {}) !== 0; return ( <>
{ if (val.key) updateFilters("sortKey", val.key); if (val.order) updateFilters("sortBy", val.order); }} /> } title="Filters" placement="bottom-end" isFiltersApplied={isFiltersApplied} >
{calculateTotalFilters(filters?.filters ?? {}) !== 0 && (
)} ); });