File size: 855 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 38 39 |
import {
RECEIVE_BOOKINGS,
RECEIVE_BOOKING,
REMOVE_BOOKING
} from '../actions/booking_actions';
import { RECEIVE_USER } from '../actions/user_actions';
import merge from 'lodash/merge';
const bookingsReducer = (state = {}, action) => {
Object.freeze(state);
let newState = merge({}, state);
switch (action.type) {
case RECEIVE_BOOKINGS:
// return action.bookings;
return merge({}, state, action.bookings);
case RECEIVE_BOOKING:
return merge({}, state, action.payload.bookings);
case REMOVE_BOOKING:
delete newState[action.bookingId];
return newState;
case RECEIVE_USER:
return merge({},state,action.payload.bookings);
default:
return state;
}
};
export default bookingsReducer;
|