diff options
author | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-20 15:14:13 +0200 |
---|---|---|
committer | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-20 15:14:13 +0200 |
commit | 240246ea132cc736c6eaa70ed79f2ec78d1d4636 (patch) | |
tree | a45a5c81de9f650fcd18190d90049f67c0f63b97 /frontend/src/redux/errors.js | |
parent | Upgrade react-scripts to 1.0.1 (diff) | |
download | seven-wonders-240246ea132cc736c6eaa70ed79f2ec78d1d4636.tar.gz seven-wonders-240246ea132cc736c6eaa70ed79f2ec78d1d4636.tar.bz2 seven-wonders-240246ea132cc736c6eaa70ed79f2ec78d1d4636.zip |
Add prettier and format js files
Diffstat (limited to 'frontend/src/redux/errors.js')
-rw-r--r-- | frontend/src/redux/errors.js | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/frontend/src/redux/errors.js b/frontend/src/redux/errors.js index 7d113db1..eb807fdc 100644 --- a/frontend/src/redux/errors.js +++ b/frontend/src/redux/errors.js @@ -1,37 +1,40 @@ -import Immutable from 'seamless-immutable' +import Immutable from "seamless-immutable"; export const types = { - ERROR_RECEIVED_ON_WS: 'ERROR/RECEIVED_ON_WS', -} + ERROR_RECEIVED_ON_WS: "ERROR/RECEIVED_ON_WS" +}; export const actions = { - errorReceived: (error) => ({ + errorReceived: error => ({ type: types.ERROR_RECEIVED_ON_WS, error - }), -} + }) +}; const initialState = Immutable.from({ nextId: 0, history: [] -}) +}); export default (state = initialState, action) => { switch (action.type) { case types.ERROR_RECEIVED_ON_WS: - let error = Object.assign({id: state.nextId, timestamp: new Date()}, action.error); - let newState = state.set('nextId', state.nextId + 1) - newState = addErrorToHistory(newState, error) - return newState + let error = Object.assign( + { id: state.nextId, timestamp: new Date() }, + action.error + ); + let newState = state.set("nextId", state.nextId + 1); + newState = addErrorToHistory(newState, error); + return newState; default: - return state + return state; } -} +}; function addErrorToHistory(state, error) { - return addToArray(state, 'history', error); + return addToArray(state, "history", error); } function addToArray(state, arrayKey, element) { - return state.set(arrayKey, state[arrayKey].concat([ element ])); + return state.set(arrayKey, state[arrayKey].concat([element])); } |