forked from timaschew/react-redux-foundation-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (21 loc) · 716 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import * as ActionTypes from '../actions'
import { routeReducer } from 'react-router-redux'
import { combineReducers } from 'redux'
import update from 'react-addons-update'
function notifications(state = {callouts: []}, action) {
switch (action.type) {
case ActionTypes.CREATE_CALLOUT:
return update(state, {callouts: {$push: [action.payload]}})
case ActionTypes.REMOVE_CALLOUT:
const { id } = action.payload
const index = state.callouts.map(item => item.id).indexOf(id)
return update(state, {callouts: {$splice: [[index, 1]]}})
default:
return state
}
}
const rootReducer = combineReducers({
routing: routeReducer,
notifications
})
export default rootReducer