2019-06-19 16:37:03 -04:00
|
|
|
import { ADD_ARTICLE } from '../constants/action-types'
|
2019-06-21 00:59:25 -04:00
|
|
|
import { SET_CANDIDATE } from '../constants/action-types'
|
2019-06-21 11:51:07 -04:00
|
|
|
import { DATA_LOADED } from '../constants/action-types'
|
|
|
|
import { DATA_LOADED_TO_ADD } from '../constants/action-types'
|
2019-06-19 14:24:21 -04:00
|
|
|
|
|
|
|
const initialState = {
|
2019-06-19 17:08:53 -04:00
|
|
|
articles: [],
|
2019-06-21 00:59:25 -04:00
|
|
|
remoteArticles: [],
|
2019-06-25 01:40:15 -04:00
|
|
|
remoteArticlesHillary: [],
|
2019-06-21 00:59:25 -04:00
|
|
|
candidate: ''
|
2019-06-19 14:24:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function rootReducer(state = initialState, action) {
|
|
|
|
if (action.type === ADD_ARTICLE) {
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
articles: state.articles.concat(action.payload)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-21 00:59:25 -04:00
|
|
|
else if (action.type === SET_CANDIDATE) {
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
candidate: action.payload
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-21 11:51:07 -04:00
|
|
|
else if (action.type === DATA_LOADED) {
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
remoteArticles: action.payload.message.statuses
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (action.type === DATA_LOADED_TO_ADD) {
|
2019-06-22 19:57:06 -04:00
|
|
|
return Object.assign({}, state, {
|
2019-06-25 01:40:15 -04:00
|
|
|
remoteArticlesHillary: state.remoteArticlesHillary.concat(action.payload)
|
2019-06-19 17:08:53 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-19 14:24:21 -04:00
|
|
|
return state
|
|
|
|
}
|
|
|
|
|
|
|
|
export default rootReducer
|