1 import { RoutingContainer } from 'features/shared/components'
2 import { humanize } from 'utility/string'
3 import actions from 'actions'
5 const makeRoutes = (store, type, List, New, Show, Update, options = {}) => {
6 const loadPage = () => {
7 store.dispatch(actions[type].fetchAll())
10 const childRoutes = []
19 if (options.childRoutes) {
20 childRoutes.push(...options.childRoutes)
38 path: options.path || type + 's',
39 component: RoutingContainer,
40 name: options.name || humanize(type + 's'),
43 onEnter: (nextState, replace) => {
44 loadPage(nextState, replace)
46 onChange: (_, nextState, replace) => { loadPage(nextState, replace) }
48 childRoutes: childRoutes
52 export default makeRoutes