diff options
Diffstat (limited to 'src/client/react/users.js')
-rw-r--r-- | src/client/react/users.js | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/client/react/users.js b/src/client/react/users.js deleted file mode 100644 index 01ff093..0000000 --- a/src/client/react/users.js +++ /dev/null @@ -1,66 +0,0 @@ -/* global USERS */ - -import { combineReducers, createStore } from 'redux'; - -const getId = ({ type, value }) => `${type}/${value}`; - -const byId = (state = {}, action) => { - switch (action.type) { - case 'USERS/ADD_USER': - return { - ...state, - [action.user.id]: { - ...action.user, - }, - }; - default: - return state; - } -}; - -const allIds = (state = [], action) => { - switch (action.type) { - case 'USERS/ADD_USER': - return [ - ...state, - action.user.id, - ]; - default: - return state; - } -}; - -const allUsers = (state = [], action) => { - switch (action.type) { - case 'USERS/ADD_USER': - return [ - ...state, - { - ...action.user, - }, - ]; - default: - return state; - } -}; - -const store = createStore(combineReducers({ - byId, - allIds, - allUsers, -})); - -USERS.forEach((user) => { - store.dispatch({ - type: 'USERS/ADD_USER', - user: { - type: user.type, - value: user.value, - id: getId(user), - }, - }); -}); - -const users = store.getState(); - -export default users; |