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