import {setScrollBehaviour, setSearchFormCollapsed} from './modules/list/actions'

const isDefined = value => value !== undefined

export const getDispatchActions = input =>
  actionSettings.reduce((acc, actionSetting) => {
    if (isDefined(input[actionSetting.name])) {
      acc.push(actionSetting.action(...actionSetting.argsFactory(input)))
    }
    return acc
  }, [])

const actionSettings = [
  {
    name: 'searchFormCollapsed',
    action: setSearchFormCollapsed,
    argsFactory: input => [input.searchFormCollapsed]
  },
  {
    name: 'scrollBehaviour',
    action: setScrollBehaviour,
    argsFactory: input => [input.scrollBehaviour]
  }
]

@@ -1,8 +1,43 @@
+import %7Baction%7D from 'tocco-util'%0A%0A
 import %7B
@@ -115,56 +115,8 @@
 s'%0A%0A
-const isDefined = value =%3E value !== undefined%0A%0A
 expo
@@ -157,209 +157,56 @@
 t =%3E
-%0A 
  action
-Settings.reduce((acc, actionSetting) =%3E %7B%0A    if (isDefined(input%5BactionSetting.name%5D)) %7B%0A      acc.push(actionSetting.action(...actionSetting.argsFactory(input)))%0A    %7D%0A    return acc%0A  %7D, %5B%5D
+.getDispatchActions(input, actionSettings
 )%0A%0Ac

refactor dispatch actions