From c34f06f130c15c400a0cba1b14a07021d7e52776 Mon Sep 17 00:00:00 2001 From: Aditya Sankaran Date: Wed, 27 Nov 2019 20:57:42 -0500 Subject: [PATCH] formatted feed and userline --- functions/handlers/post.js | 4 +--- twistter-frontend/src/pages/Home.js | 10 +++++++--- twistter-frontend/src/pages/user.js | 14 ++++++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/functions/handlers/post.js b/functions/handlers/post.js index 407a85c..2ccdc8e 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -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.' }); } }) diff --git a/twistter-frontend/src/pages/Home.js b/twistter-frontend/src/pages/Home.js index ff90580..fd288c0 100644 --- a/twistter-frontend/src/pages/Home.js +++ b/twistter-frontend/src/pages/Home.js @@ -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 { } {post.userHandle} - {post.createdAt} + {post.createdAt.substring(0,10) + + " " + post.createdAt.substring(11,19)}
{post.microBlogTitle} {post.body}
- Topics: {post.microBlogTopics} + Topics: {post.microBlogTopics.join("," + " ")}
- Likes {post.likeCount} Comments {post.commentCount} + Likes {post.likeCount} diff --git a/twistter-frontend/src/pages/user.js b/twistter-frontend/src/pages/user.js index 3340b47..cada325 100644 --- a/twistter-frontend/src/pages/user.js +++ b/twistter-frontend/src/pages/user.js @@ -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)); } @@ -124,7 +127,9 @@ class user extends Component { let imageMarkup = this.state.imageUrl ? () : (); - + + + let postMarkup = this.state.posts ? ( this.state.posts.map(post => @@ -136,14 +141,15 @@ class user extends Component { } {post.userHandle} - {post.createdAt} + {post.createdAt.substring(0,10) + + " " + post.createdAt.substring(11,19)}
{post.microBlogTitle} {post.body}
- Topics: {post.microBlogTopics} + Topics: {post.microBlogTopics.join("," + " ")}
- Likes {post.likeCount} Comments {post.commentCount} + Likes {post.likeCount}
)