I stack into multiple filters right now is
const DashboardPage = () => {
const { device } = useSelector((state) => state.device);
const [q, setQ] = useState("");
const [searchParam] = useState(["deviceName"]);
const [filterParam, setFilterParam] = useState(["All"]);
function search(device) {
return device.filter((item) => {
if (filterParam == "All") {
return searchParam.some((newItem) => {
return (
item[newItem].toString().toLowerCase().indexOf(q.toLowerCase()) > -1
);
});
} else if (item.deviceStatus == filterParam) {
return searchParam.some((newItem) => {
return (
item[newItem].toString().toLowerCase().indexOf(q.toLowerCase()) > -1
);
});
}
});
}
return( <input type="search"
value={q}
onChange={(e) => setQ(e.target.value)}/>
search(device).map((devicedetails) => {}) )
Unfortunately, I cannot use more than a filter per search. The fixed problem may be simple, but I cannot understand it now.
