Created
June 14, 2019 15:33
-
-
Save yosevu/1c266e1b4581faf994be29fb0379a838 to your computer and use it in GitHub Desktop.
Transform Style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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