s/restaurants/suggestions/

This commit is contained in:
2016-12-24 10:00:21 -05:00
parent 4c7b9310c0
commit c4f07d3b3e
14 changed files with 237 additions and 215 deletions

View File

@ -3,13 +3,13 @@ var Redux = require('redux');
var UserReducer = require('./UserReducer');
var SessionReducer = require('./SessionReducer');
var AttendeeReducer = require('./AttendeeReducer');
var RestaurantReducer = require('./RestaurantReducer');
var SuggestionReducer = require('./SuggestionReducer');
var ErrorReducer = require('./ErrorReducer');
module.exports = Redux.combineReducers({
user: UserReducer,
session: SessionReducer,
attendees: AttendeeReducer,
restaurants: RestaurantReducer,
suggestions: SuggestionReducer,
error: ErrorReducer
});

View File

@ -1,26 +0,0 @@
var assign = require('object-assign');
var RestaurantConstants = require('../constants/RestaurantConstants');
var UserConstants = require('../constants/UserConstants');
module.exports = function(state = {}, action) {
switch (action.type) {
case RestaurantConstants.RESTAURANTS_FETCHED:
var restaurants = {};
for (var i = 0; i < action.restaurants.length; i++) {
var restaurant = action.restaurants[i];
restaurants[restaurant.RestaurantId] = restaurant;
}
return restaurants;
case RestaurantConstants.RESTAURANT_CREATED:
var restaurant = action.restaurant;
var restaurants = assign({}, state, {
[restaurant.RestaurantId]: restaurant
});
return restaurants;
case UserConstants.USER_LOGGEDOUT:
return {};
default:
return state;
}
};

View 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;
}
};