import { useCallback } from "react"; import { observer } from "mobx-react"; // icons import { ChevronDown, ListFilter } from "lucide-react"; // types import { TProjectFilters } from "@plane/types"; // hooks import { useAppRouter, useMember, useProjectFilter } from "@/hooks/store"; // components import { FiltersDropdown } from "../issues"; import { ProjectFiltersSelection, ProjectOrderByDropdown } from "./dropdowns"; 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] ); return (