s/restaurants/suggestions/
This commit is contained in:
26
js/reducers/SuggestionReducer.js
Normal file
26
js/reducers/SuggestionReducer.js
Normal file
@ -0,0 +1,26 @@
|
||||
var assign = require('object-assign');
|
||||
|
||||
var SuggestionConstants = require('../constants/SuggestionConstants');
|
||||
var UserConstants = require('../constants/UserConstants');
|
||||
|
||||
module.exports = function(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case SuggestionConstants.SUGGESTIONS_FETCHED:
|
||||
var suggestions = {};
|
||||
for (var i = 0; i < action.suggestions.length; i++) {
|
||||
var suggestion = action.suggestions[i];
|
||||
suggestions[suggestion.SuggestionId] = suggestion;
|
||||
}
|
||||
return suggestions;
|
||||
case SuggestionConstants.SUGGESTION_CREATED:
|
||||
var suggestion = action.suggestion;
|
||||
var suggestions = assign({}, state, {
|
||||
[suggestion.SuggestionId]: suggestion
|
||||
});
|
||||
return suggestions;
|
||||
case UserConstants.USER_LOGGEDOUT:
|
||||
return {};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user