diff --git a/functions/handlers/post.js b/functions/handlers/post.js index e3d0c01..dc88e45 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -1,17 +1,17 @@ /* eslint-disable promise/always-return */ const admin = require('firebase-admin'); -exports.putPost = (req, res) => { +exports.putPost = (req, res) => { const newPost = { body: req.body.body, - userHandle: req.body.userHandle, + userHandle: req.user.handle, userImage: req.body.userImage, + userID: req.user.uid, microBlogTitle: req.body.microBlogTitle, createdAt: new Date().toISOString(), likeCount: 0, commentCount: 0, microBlogTopics: req.body.microBlogTopics - }; admin.firestore().collection('posts').add(newPost) @@ -27,7 +27,7 @@ exports.putPost = (req, res) => { }; exports.getallPostsforUser = (req, res) => { - admin.firestore().collection('posts').where('userHandle', '==', 'new user' ).get() + admin.firestore().collection('posts').where('userHandle', '==', req.userData.handle ).get() .then((data) => { let posts = []; data.forEach(function(doc) { diff --git a/twistter-frontend/src/App.js b/twistter-frontend/src/App.js index b767156..d2b880c 100644 --- a/twistter-frontend/src/App.js +++ b/twistter-frontend/src/App.js @@ -67,7 +67,6 @@ class App extends Component { - {/* */} diff --git a/twistter-frontend/src/Writing_Microblogs.js b/twistter-frontend/src/Writing_Microblogs.js index b1570d8..26f061d 100644 --- a/twistter-frontend/src/Writing_Microblogs.js +++ b/twistter-frontend/src/Writing_Microblogs.js @@ -5,7 +5,7 @@ import axios from 'axios'; class Writing_Microblogs extends Component { - + constructor(props) { super(props); this.state = { @@ -15,13 +15,13 @@ class Writing_Microblogs extends Component { characterCount: 250 }; - + 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) { @@ -33,10 +33,10 @@ class Writing_Microblogs extends Component { } handleSubmit(event) { - // alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value); + const postData = { - body: this.state.value, - userHandle: "new user", + body: this.state.value, + userImage: "bing-url", microBlogTitle: this.state.title, microBlogTopics: this.state.topics.split(', ') @@ -102,7 +102,7 @@ class Writing_Microblogs extends Component { ); } - + } export default Writing_Microblogs; \ No newline at end of file diff --git a/twistter-frontend/src/components/layout/NavBar.js b/twistter-frontend/src/components/layout/NavBar.js index 5f8d28d..f719ab8 100644 --- a/twistter-frontend/src/components/layout/NavBar.js +++ b/twistter-frontend/src/components/layout/NavBar.js @@ -1,7 +1,7 @@ /* eslint-disable */ import React, { Component } from 'react'; import { Link } from 'react-router-dom'; -// import PropTypes from 'prop-types'; +import PropTypes from 'prop-types'; // Material UI stuff import AppBar from '@material-ui/core/AppBar'; @@ -10,70 +10,63 @@ import Button from '@material-ui/core/Button'; import withStyles from "@material-ui/core/styles/withStyles"; // Redux stuff -// import { logoutUser } from '../../redux/actions/userActions'; -// import { connect } from 'react-redux'; - -// const styles = { -// form: { -// textAlign: "center" -// }, -// textField: { -// marginBottom: 30 -// }, -// pageTitle: { -// marginBottom: 40 -// }, -// button: { -// positon: "relative", -// marginBottom: 30 -// }, -// progress: { -// position: "absolute" -// } -// }; - - - +import { connect } from 'react-redux'; +const styles = { + form: { + textAlign: "center" + }, + textField: { + marginBottom: 30 + }, + pageTitle: { + marginBottom: 40 + }, + button: { + positon: "relative", + marginBottom: 30 + }, + progress: { + position: "absolute" + } +}; - export class Navbar extends Component { - render() { +export class Navbar extends Component { + render() { + const authenticated = this.props.user.authenticated; return ( - - } + {!authenticated && - } + {authenticated && - } + {authenticated && + } ) } } -// const mapStateToProps = (state) => ({ -// user: state.user -// }) +const mapStateToProps = (state) => ({ + user: state.user +}) -// const mapActionsToProps = { logoutUser }; +Navbar.propTypes = { + user: PropTypes.object.isRequired, + classes: PropTypes.object.isRequired +} -// Navbar.propTypes = { -// logoutUser: PropTypes.func.isRequired, -// user: PropTypes.object.isRequired, -// classes: PropTypes.object.isRequired -// } +export default connect(mapStateToProps)(withStyles(styles)(Navbar)); -// export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Navbar)); - -export default Navbar; +// export default Navbar;