formatted feed and userline

This commit is contained in:
Aditya Sankaran 2019-11-27 20:57:42 -05:00
parent e8110d643f
commit c34f06f130
3 changed files with 18 additions and 10 deletions

View File

@ -105,12 +105,11 @@ exports.quoteWithPost = (req, res) => {
})
}
else {
console.log("Post has already been quoted.");
return res.status(400).json({ error: 'Post has already been quoted.' });
}
})
.catch((err) => {
return res.status(500).json({error: 'Something is wrong'});
return res.status(500).json({error: err});
})
@ -151,7 +150,6 @@ exports.quoteWithoutPost = (req, res) => {
})
}
else {
console.log("Post has already been quoted.");
return res.status(400).json({ error: 'Post has already been quoted.' });
}
})

View File

@ -32,6 +32,9 @@ class Home extends Component {
this.setState({
posts: res.data
})
this.setState({posts: (this.state.posts).sort((a,b) =>
-a.createdAt.localeCompare(b.createdAt))
})
})
.catch(err => console.log(err));
}
@ -51,14 +54,15 @@ class Home extends Component {
}
</Typography>
<Typography variant="h7"><b>{post.userHandle}</b></Typography>
<Typography variant="body2" color={"textSecondary"}>{post.createdAt}</Typography>
<Typography variant="body2" color={"textSecondary"}>{post.createdAt.substring(0,10) +
" " + post.createdAt.substring(11,19)}</Typography>
<br />
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
<Typography variant="body2">{post.body}</Typography>
<br />
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics}</Typography>
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics.join("," + " ")}</Typography>
<br />
<Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount} Comments {post.commentCount}</Typography>
<Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount}</Typography>
<Like microBlog = {post.postId}></Like>
<Quote microblog = {post.postId}></Quote>
</CardContent>

View File

@ -95,6 +95,9 @@ class user extends Component {
this.setState({
posts: res.data
})
this.setState({posts: (this.state.posts).sort((a,b) =>
-a.createdAt.localeCompare(b.createdAt))
})
})
.catch(err => console.log(err));
}
@ -125,6 +128,8 @@ class user extends Component {
let imageMarkup = this.state.imageUrl ? (<img src={this.state.imageUrl} height="150" width="150" />) :
(<img src={noImage} height="150" width="150"/>);
let postMarkup = this.state.posts ? (
this.state.posts.map(post =>
<Card>
@ -136,14 +141,15 @@ class user extends Component {
}
</Typography>
<Typography variant="h7"><b>{post.userHandle}</b></Typography>
<Typography variant="body2" color={"textSecondary"}>{post.createdAt}</Typography>
<Typography variant="body2" color={"textSecondary"}>{post.createdAt.substring(0,10) +
" " + post.createdAt.substring(11,19)}</Typography>
<br />
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
<Typography variant="body2">{post.body}</Typography>
<br />
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics}</Typography>
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics.join("," + " ")}</Typography>
<br />
<Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount} Comments {post.commentCount}</Typography>
<Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount}</Typography>
</CardContent>
</Card>
)