import { useCallback } from "react"; import { observer } from "mobx-react"; // icons import { ChevronDown, ListFilter } from "lucide-react"; // types import { TProjectFilters } from "@plane/types"; // hooks import { FiltersDropdown } from "@/components/issues/issue-layouts"; import { ProjectFiltersSelection, ProjectOrderByDropdown } from "@/components/project/dropdowns"; // helpers import { calculateTotalFilters } from "@/helpers/filter.helper"; // hooks import { useAppRouter, useMember, useProjectFilter } from "@/hooks/store"; const ProjectsMobileHeader = observer(() => { const { currentWorkspaceDisplayFilters: displayFilters, currentWorkspaceFilters: filters, updateDisplayFilters, updateFilters, } = useProjectFilter(); const { workspaceSlug } = useAppRouter(); const { workspace: { workspaceMemberIds }, } = useMember(); const handleFilters = useCallback( (key: keyof TProjectFilters, value: string | string[]) => { if (!workspaceSlug) return; const newValues = filters?.[key] ?? []; if (Array.isArray(value)) value.forEach((val) => { if (!newValues.includes(val)) newValues.push(val); else newValues.splice(newValues.indexOf(val), 1); }); else { if (filters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1); else newValues.push(value); } updateFilters(workspaceSlug, { [key]: newValues }); }, [filters, updateFilters, workspaceSlug] ); const isFiltersApplied = calculateTotalFilters(filters ?? {}) !== 0; return (