import { combineReducers } from 'redux'


// action creators and reducers in one file as suggested by https://github.com/erikras/ducks-modular-redux

// actions
const UPDATE_INDIVIDUALS_BY_GUID = 'UPDATE_INDIVIDUALS_BY_GUID'
const UPDATE_FAMILIES_BY_GUID = 'UPDATE_FAMILIES_BY_GUID'

// action creators
export const updateIndividualsByGuid = individualsByGuid => ({
  type: UPDATE_INDIVIDUALS_BY_GUID,
  individualsByGuid,
})

export const updateFamiliesByGuid = familiesByGuid => ({
  type: UPDATE_FAMILIES_BY_GUID,
  familiesByGuid,
})


// reducers
const individualsByGuidReducer = (individualsByGuid = {}, action) => {
  switch (action.type) {
    case UPDATE_INDIVIDUALS_BY_GUID:
      return { ...individualsByGuid, ...action.individualsByGuid }
    default:
      return individualsByGuid
  }
}

const familiesByGuidReducer = (familiesByGuid = {}, action) => {
  switch (action.type) {
    case UPDATE_FAMILIES_BY_GUID: {
      return { ...familiesByGuid, ...action.familiesByGuid }
    }
    default:
      return familiesByGuid
  }
}

const zeroActionsReducer = (state = {}) => {
  return state
}

const userReducer = zeroActionsReducer
const projectReducer = zeroActionsReducer
const familyGuidToIndivGuidsReducer = zeroActionsReducer

const rootReducer = combineReducers({
  familiesByGuid: familiesByGuidReducer,
  individualsByGuid: individualsByGuidReducer,
  familyGuidToIndivGuids: familyGuidToIndivGuidsReducer,
  user: userReducer,
  project: projectReducer,
})

export default rootReducer

// selectors
//export const getUser = (state) => state.stored.user

@@ -34,16 +34,88 @@
 redux'%0A%0A
+import %7B zeroActionsReducer %7D from '../../../shared/utils/reducerUtils'%0A
 %0A// acti
@@ -1113,210 +1113,8 @@
 %0A%7D%0A%0A
-const zeroActionsReducer = (state = %7B%7D) =%3E %7B%0A  return state%0A%7D%0A%0Aconst userReducer = zeroActionsReducer%0Aconst projectReducer = zeroActionsReducer%0Aconst familyGuidToIndivGuidsReducer = zeroActionsReducer%0A%0A
 cons
@@ -1261,37 +1261,26 @@
 vGuids: 
-familyGuidToIndivGuid
+zeroAction
 sReducer
@@ -1289,20 +1289,27 @@
   user: 
-user
+zeroActions
 Reducer,
@@ -1320,23 +1320,27 @@
 roject: 
-project
+zeroActions
 Reducer,

use shared utils reducers