File size: 954 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { RECEIVE_CURRENT_USER } from '../actions/session_actions';

import merge from 'lodash/merge';
import { RECEIVE_SPOT } from '../actions/spot_actions';
import {RECEIVE_USER } from '../actions/user_actions';

const usersReducer = (state = {}, action) => {
    Object.freeze(state);

    let newState = merge({},state);

    switch (action.type) {
        
        // case RECEIVE_CURRENT_USER:
        //     newState[action.currentUser.id] = action.currentUser;    
        //     return newState;

        case RECEIVE_CURRENT_USER:
            return merge({}, state, action.currentUser.users);

        case RECEIVE_SPOT:
            return merge({}, state, action.payload.users);

        case RECEIVE_USER:
            return merge({}, state, action.payload.users);
        
        default:
            return state;
    }
};

export default usersReducer;


// case RECEIVE_CURRENT_USER:
// return merge({}, state, action.currentUser.users);