9 lines
385 B
JavaScript
9 lines
385 B
JavaScript
import dateFormat from 'dateformat';
|
|
import { dateFormats } from './constants';
|
|
|
|
export const filterBySearchTerm = (data = [], searchTerm = '', filterByKey = 'name') => {
|
|
if (!searchTerm?.length) return data;
|
|
return data.filter((item) => item[filterByKey].toLowerCase().includes(searchTerm.toLowerCase()));
|
|
};
|
|
|
|
export const toYmd = (date) => dateFormat(date, dateFormats.isoDate);
|