Files
freeCodeCamp/common/app/redux/entities-reducer.js

32 lines
596 B
JavaScript
Raw Normal View History

import { updateUserPoints } from './types';
2016-03-10 17:21:46 -08:00
const initialState = {
superBlock: {},
block: {},
2016-03-10 17:21:46 -08:00
challenge: {},
user: {}
2016-03-10 17:21:46 -08:00
};
export default function entities(state = initialState, action) {
const { type, payload: { username, points } = {} } = action;
if (type === updateUserPoints) {
return {
...state,
user: {
...state.user,
[username]: {
...state.user[username],
points
}
}
};
}
2016-03-10 17:21:46 -08:00
if (action.meta && action.meta.entities) {
return {
...state,
...action.meta.entities
};
}
return state;
}