Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/ui-presets / src / presets / ProductOptions / state / fromSelectionToAttributes.tsx
Size: Mime:
/* eslint-disable max-statements */
import makeSelectState from './makeMultiState'

const fromSelectionToAttributes = (props, name) => {
  let {
    /**
     * @todo @fixme - does not need to be like this!!!
     * @description defaults
     */
    list = [],
    type,
  } = props

  /**
   * @fixme - should be done in data  later
   */
  if (type === 'fit' || type === 'style1') {
    type = 'style'
  }

  const state = makeSelectState(name)

  // selectableOptions.fit
  const selectedForType = list[type]
  const shouldBeSelected = selectedForType === name

  // selectedForType.includes(name)
  const shouldBeDisabled = false

  if (shouldBeSelected) {
    state.select()
  } else if (shouldBeDisabled) {
    state.disable()
  }

  /**
   * @todo this logic is very confusing
   * @todo @deepak #help
   */

  return state
}

export { fromSelectionToAttributes }
export default fromSelectionToAttributes