2018-02-25 00:17:04 +01:00
|
|
|
import { actionTypes } from './actions'
|
|
|
|
|
|
|
|
export const initialState = {
|
|
|
|
data: null,
|
|
|
|
error: false
|
|
|
|
}
|
|
|
|
|
2018-08-20 08:31:24 +02:00
|
|
|
function reducer (state = initialState, action) {
|
2018-02-25 00:17:04 +01:00
|
|
|
switch (action.type) {
|
|
|
|
case actionTypes.LOAD_DATA_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...{ data: action.data }
|
|
|
|
}
|
|
|
|
|
|
|
|
case actionTypes.LOAD_DATA_ERROR:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...{ error: action.error }
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default reducer
|