diff --git a/functions/handlers/post.js b/functions/handlers/post.js index d15ea33..20528c0 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -11,6 +11,7 @@ exports.putPost = (req, res) => { createdAt: new Date().toISOString(), likeCount: 0, commentCount: 0, + microBlogTopics: req.body.microBlogTopics }; diff --git a/functions/index.js b/functions/index.js index 04d3b4e..b9c73d4 100644 --- a/functions/index.js +++ b/functions/index.js @@ -43,7 +43,8 @@ const {putPost, getallPostsforUser} = require('./handlers/post'); app.get('/getallPostsforUser', getallPostsforUser); // Adds one post to the database -app.post('/putPost', fbAuth, putPost); +app.post('/putPost', firebaseAuth, putPost); + exports.api = functions.https.onRequest(app); \ No newline at end of file diff --git a/twistter-frontend/src/Userline.js b/twistter-frontend/src/Userline.js index 51d74f4..e8168ce 100644 --- a/twistter-frontend/src/Userline.js +++ b/twistter-frontend/src/Userline.js @@ -9,7 +9,8 @@ class Userline extends Component { { super(props); this.state = { - microBlogs : [] + microBlogs : [], + } } @@ -21,12 +22,16 @@ class Userline extends Component { const post = res.data; this.setState({microBlogs : post}) - }) + }) + + } render() { + let sortedPosts = []; + return (
{microBlog.body}
)} diff --git a/twistter-frontend/src/Writing_Microblogs.js b/twistter-frontend/src/Writing_Microblogs.js index 1858193..0c3ddcc 100644 --- a/twistter-frontend/src/Writing_Microblogs.js +++ b/twistter-frontend/src/Writing_Microblogs.js @@ -11,6 +11,7 @@ class Writing_Microblogs extends Component { this.state = { value: '', title: '', + topics: '', characterCount: 10 }; @@ -19,12 +20,18 @@ class Writing_Microblogs extends Component { this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.handleChangeforPost = this.handleChangeforPost.bind(this); + this.handleChangeforTopics = this.handleChangeforTopics.bind(this); + } handleChange(event) { this.setState( {title: event.target.value }); } + handleChangeforTopics(event) { + this.setState( {topics: event.target.value}); + } + handleSubmit(event) { // alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value); @@ -33,15 +40,16 @@ class Writing_Microblogs extends Component { { body: this.state.value, userHandle: "new user", userImage: "bing-url", - microBlogTitle: this.state.title - + microBlogTitle: this.state.title, + microBlogTopics: this.state.topics.split(', ') + }, { headers: { 'Content-Type': 'application/json'} } ) console.log(response.data); event.preventDefault(); - this.setState({value: '', title: '',characterCount: 10}) + this.setState({value: '', title: '',characterCount: 10, topics: ''}) } handleChangeforPost(event) { @@ -55,13 +63,18 @@ class Writing_Microblogs extends Component { } - render() { return (