import React from 'react'; import FriendsContainer from '../friend_request/friends_container'; import PostIndexContainer from '../posts/post_index_container'; class ProfilePicture extends React.Component{ constructor(props){ super(props); this.state = {imageFile:null,imageUrl:null}; this.updateFile =this.updateFile.bind(this); } updateFile(e) { const file = e.currentTarget.files[0]; const fileReader = new FileReader(); const formData = new FormData(); fileReader.onloadend = function () { this.setState({ imageFile: file, imageUrl: fileReader.result }); }.bind(this); if (file) { fileReader.readAsDataURL(file); formData.append("user[profile_image_url]", file); this.props.updateUser(formData); } } updateProfilePicture(){ if (this.props.currentUser.id === this.props.user.id){ return( ); }else{ return (
); } } renderPosts(){ if(this.props.currentUser.id === this.props.user.id || this.props.currentUser.friends.includes(this.props.user.id)){ return(