Can now display post body on profile page

This commit is contained in:
Aaron Sun 2019-10-30 11:40:44 -04:00
parent 8438ce27cf
commit cd19364efc

View File

@ -63,6 +63,7 @@ class user extends Component {
}); });
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
axios axios
.get("/getAllTopics") .get("/getAllTopics")
.then(res => { .then(res => {
@ -71,16 +72,25 @@ class user extends Component {
}) })
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
axios
.get("/getallPostsforUser")
.then(res => {
console.log(res.data);
this.setState({
posts: res.data
})
})
.catch(err => console.log(err));
} }
render() { render() {
const classes = this.props; const classes = this.props;
//const authenticated = this.props.user.authenticated;
let profileMarkup = this.state.profile ? ( let profileMarkup = this.state.profile ? (
<p> <p>
<Typography variant='h5'>{this.state.profile}</Typography> <Typography variant='h5'>{this.state.profile}</Typography>
</p>) : (<p>loading username...</p>); </p>) : (<p>loading username...</p>);
let topicsMarkup = this.state.topics ? ( let topicsMarkup = this.state.topics ? (
this.state.topics.map(topic => <MyChip this.state.topics.map(topic => <MyChip
label={{topic}.topic.topic} label={{topic}.topic.topic}
@ -96,6 +106,10 @@ class user extends Component {
/> />
) : (<img src={noImage}/>); ) : (<img src={noImage}/>);
let postMarkup = this.state.posts ? (
this.state.posts.map(post => <p>{post.body}</p>)
) : (<p>My Posts</p>);
return ( return (
<Grid container spacing={24}> <Grid container spacing={24}>
<Grid item sm={4} xs={8}> <Grid item sm={4} xs={8}>
@ -118,13 +132,12 @@ class user extends Component {
/> />
<br /> <br />
<Button component={ Link } to='/edit'>Edit Profile Info</Button> <Button component={ Link } to='/edit'>Edit Profile Info</Button>
{/*authenticated && <Button component={ Link } to='/edit'>Edit Profile Info</Button>*/}
</Grid> </Grid>
<Grid item sm={4} xs={8}> <Grid item sm={4} xs={8}>
<Writing_Microblogs /> <Writing_Microblogs />
</Grid> </Grid>
<Grid item sm={4} xs={8}> <Grid item sm={4} xs={8}>
<p>Post</p> {postMarkup}
</Grid> </Grid>
</Grid> </Grid>
); );