1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-redux-observable/redux/reducer.js
Tim Neutkens 9c4eefcdbf
Add prettier for examples directory (#5909)
* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
2018-12-17 17:34:32 +01:00

29 lines
650 B
JavaScript

import * as types from './actionTypes'
const INITIAL_STATE = {
nextCharacterId: 1,
character: {},
isFetchedOnServer: false,
error: null
}
export default function reducer (state = INITIAL_STATE, { type, payload }) {
switch (type) {
case types.FETCH_CHARACTER_SUCCESS:
return {
...state,
character: payload.response,
isFetchedOnServer: payload.isServer,
nextCharacterId: state.nextCharacterId + 1
}
case types.FETCH_CHARACTER_FAILURE:
return {
...state,
error: payload.error,
isFetchedOnServer: payload.isServer
}
default:
return state
}
}