"use client"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { useEffect, useState } from "react"; import { FILTER_SELECT_CLASS } from "@/components/ui/Field"; import { SearchInput } from "@/components/ui/SearchInput"; type EmployeeFiltersProps = { divisions: { id: string; name: string }[]; locations: { id: string; name: string }[]; }; const STATUS_OPTIONS = ["Aktiv", "Karenz", "Geplant", "Ausgetreten"] as const; export function EmployeeFilters({ divisions, locations }: EmployeeFiltersProps) { const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); const [q, setQ] = useState(searchParams.get("q") ?? ""); useEffect(() => { const handle = setTimeout(() => { const current = new URLSearchParams(searchParams.toString()); if (q) current.set("q", q); else current.delete("q"); current.delete("page"); const next = current.toString(); if (next !== searchParams.toString()) router.push(`${pathname}?${next}`); }, 300); return () => clearTimeout(handle); // eslint-disable-next-line react-hooks/exhaustive-deps }, [q]); function updateParam(key: string, value: string) { const params = new URLSearchParams(searchParams.toString()); if (value) params.set(key, value); else params.delete(key); params.delete("page"); router.push(`${pathname}?${params.toString()}`); } return (
{/* aria-label rather than a visible label: the filter bar is a single horizontal row, and each select's first option already names it on screen. */}
); }