File size: 766 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
import { connect } from 'react-redux';
import { fetchUser } from '../../actions/user_actions';
import UserShow from './user_show';
import { deleteBooking } from '../../actions/booking_actions';

const msp = (state) => {
    const userId = state.session.currentUserId;
    const user = userId ? state.entities.users[userId] : {};
    
    return ({
        userId: userId,
        user: user,
        bookings: Object.values(state.entities.bookings),
        spots: Object.values(state.entities.spots),
        currentUser: state.entities.users[state.session.currentUserId]
    });
}


const mdp = dispatch => ({
    fetchUser: (id) => dispatch(fetchUser(id)),
    deleteBooking: (id) => dispatch(deleteBooking(id))
});

export default connect(msp,mdp)(UserShow);