2016-12-23 20:38:59 -05:00
|
|
|
var assign = require('object-assign');
|
|
|
|
|
|
|
|
var AttendeeConstants = require('../constants/AttendeeConstants');
|
|
|
|
var UserConstants = require('../constants/UserConstants');
|
|
|
|
|
|
|
|
module.exports = function(state = {}, action) {
|
|
|
|
switch (action.type) {
|
|
|
|
case AttendeeConstants.ATTENDEES_FETCHED:
|
|
|
|
var attendees = {};
|
|
|
|
for (var i = 0; i < action.attendees.length; i++) {
|
|
|
|
var attendee = action.attendees[i];
|
|
|
|
attendees[attendee.AttendeeId] = attendee;
|
|
|
|
}
|
|
|
|
return attendees;
|
|
|
|
case AttendeeConstants.ATTENDEE_CREATED:
|
|
|
|
var attendee = action.attendee;
|
|
|
|
var attendees = assign({}, state, {
|
|
|
|
[attendee.AttendeeId]: attendee
|
|
|
|
});
|
|
|
|
return attendees;
|
2016-12-28 09:25:20 -05:00
|
|
|
case AttendeeConstants.ATTENDEE_REMOVED:
|
|
|
|
var attendees = assign({}, state);
|
|
|
|
delete attendees[action.attendeeId];
|
|
|
|
return attendees;
|
2016-12-23 20:38:59 -05:00
|
|
|
case UserConstants.USER_LOGGEDOUT:
|
|
|
|
return {};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|