fleet/frontend/utilities/simple_search/simple_search.js
RachelElysia 37e267bef9
TableContainer additions: simpleSearch utility and IconCell (#1404)
* Create simpleSearch and IconCell
2021-07-19 08:44:11 -07:00

20 lines
430 B
JavaScript

import { filter, includes } from "lodash";
const simpleSearch = (searchQuery = "", dictionary) => {
const lowerSearchQuery = searchQuery.toLowerCase();
const filterResults = filter(dictionary, (item) => {
if (!item.name) {
return false;
}
const lowerItemName = item.name.toLowerCase();
return includes(lowerItemName, lowerSearchQuery);
});
return filterResults;
};
export default simpleSearch;