File size: 2,019 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import React from 'react';
import BookingUser from '../booking/booking_user';
import BookingIndexItem from '../booking/booking_index_item';
import NavBarIndexContainer from '../search/navbar_index/navbar_index_container';
class UserShow extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
this.props.fetchUser(this.props.userId);
}
render() {
if (this.props.userId === undefined) return null;
if (this.props.user === undefined) return null;
if (this.props.bookings === undefined) return null;
if (this.props.spots === undefined) return null;
const bookings = this.props.bookings.map(booking => {
let spot = undefined;
this.props.spots.forEach(potentialSpot => {
if (booking.spot_id === potentialSpot.id) {
spot = potentialSpot;
}
})
return (
<BookingIndexItem
key={booking.id}
booking={booking}
spot={spot}
deleteBooking={this.props.deleteBooking}
fetchUser={this.props.fetchUser}
userId={this.props.userId}/>
)
});
return (
<div className="user-show-container">
<div className="booking-navbar-container">
<NavBarIndexContainer />
</div>
<div className='user-show'>
<div className="booking-user">
<BookingUser
currentUser={this.props.currentUser} />
</div>
<div className='spots-ul'>
<div className="welcome-guest">Your Bookings</div>
<ul>
{bookings}
</ul>
</div>
</div>
</div>
);
}
}
export default UserShow;
|