Guest User

EventsFeed.js

a guest
Nov 25th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import {
  4.   fetchEventInfo,
  5.   fetchUserImg,
  6.   attendEvent,
  7.   fetchUserInfo,
  8.   unattendEvent,
  9.   eventWallInputChange,
  10.   createPostOnEventWall
  11. } from '../actions';
  12. import Guests from './components/Guests';
  13. import NewFeeds from './components/NewFeeds';
  14. import EventInfo from './components/EventInfo';
  15. import ProfilePhoto from '../ProfilesPage/components/ProfilePhoto';
  16. import EventImg from './components/EventImg';
  17. import Navbar from '../common/Navbar';
  18. import UpdateEvent from './components/UpdateEvent';
  19. import { RightGraySideBar, LeftGraySideBar, PageContent, Feed } from '../common';
  20.  
  21. class EventsFeed extends Component {
  22.   constructor(props) {
  23.     super(props);
  24.   }
  25.   async componentWillMount() {
  26.     const eventId = this.props.match.params.id;
  27.     await this.props.fetchEventInfo(eventId);
  28.  
  29.   /* fetching user's profile picture here */
  30.     const hostId = this.props.selectedEvent.info.user_id;
  31.     const userPhoto = await this.props.fetchUserImg(hostId);
  32.   /* done fetching user's profile picture */
  33.  
  34.     await this.props.fetchUserInfo(sessionStorage.getItem('userId'));
  35.   }
  36.   onCreatePost() {
  37.     const body = this.props.eventWallPost;
  38.     const eventId = this.props.match.params.id;
  39.     const authorId = sessionStorage.getItem('userId');
  40.     this.props.createPostOnEventWall({ body, eventId, authorId}, this.props.fetchEventInfo);
  41.   }
  42.  
  43.   render() {
  44.     return (
  45.       <div id="events-feed-container">
  46.         <div>
  47.           <Navbar history={this.props.history} />
  48.         </div>
  49.         <div id="pic-wrap">  
  50.           <EventImg event={this.props.selectedEvent} />  
  51.         </div>  
  52.  
  53.         <ProfilePhoto userInfo={this.props.userInfo}> </ProfilePhoto>
  54.  
  55.           <LeftGraySideBar className="event-info-bar">
  56.             <EventInfo
  57.               event={this.props.selectedEvent}
  58.               attendEvent={this.props.attendEvent}
  59.               userInfo={this.props.userInfo}
  60.               eventId={this.props.match.params.id}
  61.               fetchEventInfo={this.props.fetchEventInfo}
  62.               unattendEvent={this.props.unattendEvent}>
  63.             </EventInfo>
  64.           <UpdateEvent id="edit_btn" history={this.props.history} eventId={this.props.match.params.id}/>
  65.  
  66.           </LeftGraySideBar>
  67.  
  68.           <PageContent pageTitle={"Event Feed"} className="event-feed"><h4>Event Feed</h4>
  69.             <div className="feed-post-bar">
  70.               <div className="wrap">
  71.                 <div className="search">
  72.                   <input
  73.                     type="text"
  74.                     className="searchTerm"
  75.                     placeholder="What's New?"
  76.                     onChange={event => this.props.eventWallInputChange(event.target.value)}
  77.                     value={this.props.eventWallPost}
  78.                   />
  79.                   <div className="post-button"><button className="btn btn-default" onClick={this.onCreatePost.bind(this)}>POST</button></div>
  80.                 </div>
  81.               </div>
  82.             </div>
  83.  
  84.             <NewFeeds event={this.props.selectedEvent} className="event-comment"/>
  85.            
  86.           </PageContent>
  87.  
  88.        
  89.           <div id="container">
  90.             <RightGraySideBar>
  91.               <Guests
  92.                 event={this.props.selectedEvent}
  93.               />
  94.             </RightGraySideBar>
  95.           </div>
  96.       </div>
  97.     );
  98.   }
  99. }
  100. function mapStateToProps({ selectedEvent, userInfo, eventWallPost }) {
  101.   console.log(selectedEvent);
  102.   return { selectedEvent, userInfo, eventWallPost };
  103. }
  104. export default connect(mapStateToProps,
  105.   {
  106.     fetchEventInfo,
  107.     attendEvent,
  108.     fetchUserImg,
  109.     fetchUserInfo,
  110.     unattendEvent,
  111.     eventWallInputChange,
  112.     createPostOnEventWall
  113.   }
  114. )(EventsFeed);
Advertisement
Add Comment
Please, Sign In to add comment