lunch/js/reducers/PopularAttendeeReducer.js

21 lines
592 B
JavaScript

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.POPULAR_ATTENDEES_FETCHED:
var attendees = [];
for (var i = 0; i < action.attendees.length; i++) {
attendees.push(action.attendees[i]);
}
attendees.sort(function(a, b){return a.Popularity - b.Popularity});
return attendees;
case UserConstants.USER_LOGGEDOUT:
return [];
default:
return state;
}
};