import { useCallback } from "react"; import { observer } from "mobx-react"; // icons import { ChevronDown, ListFilter } from "lucide-react"; // types import { TProjectFilters } from "@plane/types"; // hooks import { useApplication, 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 { router: { workspaceSlug }, } = useApplication(); 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 (
{ if (!workspaceSlug || val === displayFilters?.order_by) return; updateDisplayFilters(workspaceSlug, { order_by: val, }); }} isMobile />
} title="Filters" placement="bottom-end" menuButton={
Filters
} > { if (!workspaceSlug) return; updateDisplayFilters(workspaceSlug, val); }} memberIds={workspaceMemberIds ?? undefined} />
); }); export default ProjectsMobileHeader;