UNPKG

monday-ui-react-core

Version:

Official monday.com UI resources for application development in React.js

18 lines (15 loc) 548 B
export const getOptionsByCategories = (options, categories, filterValue) => { return options.reduce((result, option) => { const categoryId = option.categoryId; // skipping if the option doesn't have a category if (!categoryId) return result; if (categories[categoryId]?.onlyShowOnSearch && !filterValue) return result; if (result[categoryId]) { result[categoryId].push(option); } else { // eslint-disable-next-line no-param-reassign result[categoryId] = [option]; } return result; }, {}); };