Skip to content

Instantly share code, notes, and snippets.

@yosevu
Created June 14, 2019 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosevu/1c266e1b4581faf994be29fb0379a838 to your computer and use it in GitHub Desktop.
Save yosevu/1c266e1b4581faf994be29fb0379a838 to your computer and use it in GitHub Desktop.
Transform Style
const getSelectedOptions = facet => {
const options = get(
facet,
'searchFacetOptionGroupList.searchFacetOptionList'
);
const isActiveAndSelected = option =>
option.isActive === 'true' && option.isSelected === 'true';
return filter(options, isActiveAndSelected);
};
const transformStyle = facet => {
const getPath = curry((path, styleFacet) => get(styleFacet, path));
const sortOptions = curry((prop, options) =>
sortBy(options, [option => toLower(option[prop])])
);
const searchFacetOptionGroupList = flow(
getPath('searchFacetOptionGroupList.searchFacetOptionList'),
sortOptions('searchFacetOptionName')
)(facet);
return {
...facet,
searchFacetName: 'Category',
facetType: 'multi-select',
facetLayout: 'list',
inputDisplayType: 'checkbox',
searchFacetOptionGroupList,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment