mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 10:18:48 +00:00
Username and user id now show in post data
This commit is contained in:
parent
5fa4caf0a3
commit
657277bcad
@ -1,17 +1,17 @@
|
|||||||
/* eslint-disable promise/always-return */
|
/* eslint-disable promise/always-return */
|
||||||
const admin = require('firebase-admin');
|
const admin = require('firebase-admin');
|
||||||
exports.putPost = (req, res) => {
|
|
||||||
|
|
||||||
|
exports.putPost = (req, res) => {
|
||||||
const newPost = {
|
const newPost = {
|
||||||
body: req.body.body,
|
body: req.body.body,
|
||||||
userHandle: req.body.userHandle,
|
userHandle: req.user.handle,
|
||||||
userImage: req.body.userImage,
|
userImage: req.body.userImage,
|
||||||
|
userID: req.user.uid,
|
||||||
microBlogTitle: req.body.microBlogTitle,
|
microBlogTitle: req.body.microBlogTitle,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
likeCount: 0,
|
likeCount: 0,
|
||||||
commentCount: 0,
|
commentCount: 0,
|
||||||
microBlogTopics: req.body.microBlogTopics
|
microBlogTopics: req.body.microBlogTopics
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
admin.firestore().collection('posts').add(newPost)
|
admin.firestore().collection('posts').add(newPost)
|
||||||
@ -27,7 +27,7 @@ exports.putPost = (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.getallPostsforUser = (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) => {
|
.then((data) => {
|
||||||
let posts = [];
|
let posts = [];
|
||||||
data.forEach(function(doc) {
|
data.forEach(function(doc) {
|
||||||
|
|||||||
@ -67,7 +67,6 @@ class App extends Component {
|
|||||||
<Route exact path="/user" component={user} />
|
<Route exact path="/user" component={user} />
|
||||||
<Route exact path="/home" component={writeMicroblog} />
|
<Route exact path="/home" component={writeMicroblog} />
|
||||||
<Route exact path="/edit" component={editProfile} />
|
<Route exact path="/edit" component={editProfile} />
|
||||||
{/* <Route exact path="/user" component={userLine} /> */}
|
|
||||||
|
|
||||||
<AuthRoute exact path="/" component={home}/>
|
<AuthRoute exact path="/" component={home}/>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@ -33,10 +33,10 @@ class Writing_Microblogs extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit(event) {
|
handleSubmit(event) {
|
||||||
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
|
|
||||||
const postData = {
|
const postData = {
|
||||||
body: this.state.value,
|
body: this.state.value,
|
||||||
userHandle: "new user",
|
|
||||||
userImage: "bing-url",
|
userImage: "bing-url",
|
||||||
microBlogTitle: this.state.title,
|
microBlogTitle: this.state.title,
|
||||||
microBlogTopics: this.state.topics.split(', ')
|
microBlogTopics: this.state.topics.split(', ')
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
// import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
// Material UI stuff
|
// Material UI stuff
|
||||||
import AppBar from '@material-ui/core/AppBar';
|
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";
|
import withStyles from "@material-ui/core/styles/withStyles";
|
||||||
|
|
||||||
// Redux stuff
|
// Redux stuff
|
||||||
// import { logoutUser } from '../../redux/actions/userActions';
|
import { connect } from 'react-redux';
|
||||||
// import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// const styles = {
|
const styles = {
|
||||||
// form: {
|
form: {
|
||||||
// textAlign: "center"
|
textAlign: "center"
|
||||||
// },
|
},
|
||||||
// textField: {
|
textField: {
|
||||||
// marginBottom: 30
|
marginBottom: 30
|
||||||
// },
|
},
|
||||||
// pageTitle: {
|
pageTitle: {
|
||||||
// marginBottom: 40
|
marginBottom: 40
|
||||||
// },
|
},
|
||||||
// button: {
|
button: {
|
||||||
// positon: "relative",
|
positon: "relative",
|
||||||
// marginBottom: 30
|
marginBottom: 30
|
||||||
// },
|
},
|
||||||
// progress: {
|
progress: {
|
||||||
// position: "absolute"
|
position: "absolute"
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
|
|
||||||
|
export class Navbar extends Component {
|
||||||
|
render() {
|
||||||
|
const authenticated = this.props.user.authenticated;
|
||||||
|
|
||||||
export class Navbar extends Component {
|
|
||||||
render() {
|
|
||||||
return (
|
return (
|
||||||
<AppBar>
|
<AppBar>
|
||||||
<ToolBar>
|
<ToolBar>
|
||||||
<Button component={ Link } to='/'>
|
<Button component={ Link } to='/'>
|
||||||
Home
|
Home
|
||||||
</Button>
|
</Button>
|
||||||
<Button component={ Link } to='/login'>
|
{!authenticated && <Button component={ Link } to='/login'>
|
||||||
Login
|
Login
|
||||||
</Button>
|
</Button>}
|
||||||
<Button component={ Link } to='/signup'>
|
{!authenticated && <Button component={ Link } to='/signup'>
|
||||||
Sign Up
|
Sign Up
|
||||||
</Button>
|
</Button>}
|
||||||
<Button component={ Link } to='/logout'>
|
{authenticated && <Button component={ Link } to='/logout'>
|
||||||
Logout
|
Logout
|
||||||
</Button>
|
</Button>}
|
||||||
<Button component={ Link } to='/delete'>
|
{authenticated && <Button component={ Link } to='/delete'>
|
||||||
Delete Account
|
Delete Account
|
||||||
</Button>
|
</Button>}
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
// user: state.user
|
user: state.user
|
||||||
// })
|
})
|
||||||
|
|
||||||
// const mapActionsToProps = { logoutUser };
|
Navbar.propTypes = {
|
||||||
|
user: PropTypes.object.isRequired,
|
||||||
|
classes: PropTypes.object.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
// Navbar.propTypes = {
|
export default connect(mapStateToProps)(withStyles(styles)(Navbar));
|
||||||
// logoutUser: PropTypes.func.isRequired,
|
|
||||||
// user: PropTypes.object.isRequired,
|
|
||||||
// classes: PropTypes.object.isRequired
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Navbar));
|
// export default Navbar;
|
||||||
|
|
||||||
export default Navbar;
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user