21 lines
593 B
JavaScript
21 lines
593 B
JavaScript
|
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++) {
|
||
|
var suggestion = action.suggestions[i];
|
||
|
suggestions[suggestion.SuggestionId] = suggestion;
|
||
|
}
|
||
|
return suggestions;
|
||
|
case UserConstants.USER_LOGGEDOUT:
|
||
|
return {};
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
};
|