File size: 568 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { RECEIVE_CURRENT_USER } from '../actions/session_actions';
import { RECEIVE_USER } from '../actions/user_actions';

const userUrlsReducer = (state = {}, action) => {
  Object.freeze(state);
  const newState = Object.assign({}, state);

  switch (action.type) {
    case RECEIVE_CURRENT_USER:
      return Object.assign(newState, {[action.currentUser.userUrl]: action.currentUser.id});
    case RECEIVE_USER:
      return Object.assign(newState, {[action.user.userUrl]: action.user.id});
    default:
      return state;
  }
};

export default userUrlsReducer;