Add full ability to add/delete attendees

This commit is contained in:
2016-12-28 09:25:20 -05:00
parent 49893ffdb6
commit 350a30715a
15 changed files with 292 additions and 28 deletions

View File

@ -18,6 +18,10 @@ module.exports = function(state = {}, action) {
[attendee.AttendeeId]: attendee
});
return attendees;
case AttendeeConstants.ATTENDEE_REMOVED:
var attendees = assign({}, state);
delete attendees[action.attendeeId];
return attendees;
case UserConstants.USER_LOGGEDOUT:
return {};
default:

View File

@ -3,17 +3,17 @@ var assign = require('object-assign');
var AttendeeConstants = require('../constants/AttendeeConstants');
var UserConstants = require('../constants/UserConstants');
module.exports = function(state = {}, action) {
module.exports = function(state = [], action) {
switch (action.type) {
case AttendeeConstants.POPULAR_ATTENDEES_FETCHED:
var attendees = {};
var attendees = [];
for (var i = 0; i < action.attendees.length; i++) {
var attendee = action.attendees[i];
attendees[attendee.AttendeeId] = attendee;
attendees.push(action.attendees[i]);
}
attendees.sort(function(a, b){return a.Popularity - b.Popularity});
return attendees;
case UserConstants.USER_LOGGEDOUT:
return {};
return [];
default:
return state;
}

View File

@ -3,17 +3,17 @@ var assign = require('object-assign');
var SuggestionConstants = require('../constants/SuggestionConstants');
var UserConstants = require('../constants/UserConstants');
module.exports = function(state = {}, action) {
module.exports = function(state = [], action) {
switch (action.type) {
case SuggestionConstants.POPULAR_SUGGESTIONS_FETCHED:
var suggestions = {};
var suggestions = [];
for (var i = 0; i < action.suggestions.length; i++) {
var suggestion = action.suggestions[i];
suggestions[suggestion.SuggestionId] = suggestion;
suggestions.push(action.suggestions[i]);
}
suggestions.sort(function(a, b){return a.Popularity - b.Popularity});
return suggestions;
case UserConstants.USER_LOGGEDOUT:
return {};
return [];
default:
return state;
}