mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +00:00
Merge pull request #98 from ClaytonWWilson/fix_follow
add topics when publish new post
This commit is contained in:
commit
6e32b25861
@ -40,15 +40,28 @@ class Writing_Microblogs extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.post("/putPost", postData, headers)
|
.post("/putPost", postData, headers) // TODO: add topics
|
||||||
.then(res => {
|
.then(res => {
|
||||||
alert("Post was shared successfully!");
|
// alert("Post was shared successfully!");
|
||||||
console.log(res.data);
|
console.log(res.data);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
alert("An error occured.");
|
alert("An error occured.");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
console.log(postData.microBlogTopics);
|
||||||
|
postData.microBlogTopics.forEach(topic => {
|
||||||
|
axios
|
||||||
|
.post("/putTopic", {
|
||||||
|
following: topic
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.setState({ value: "", title: "", characterCount: 250, topics: "" });
|
this.setState({ value: "", title: "", characterCount: 250, topics: "" });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from "react";
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from "prop-types";
|
||||||
import { connect } from 'react-redux';
|
import { connect } from "react-redux";
|
||||||
import axios from 'axios';
|
import axios from "axios";
|
||||||
|
|
||||||
// Material UI and React Router
|
// Material UI and React Router
|
||||||
import Grid from '@material-ui/core/Grid';
|
import Grid from "@material-ui/core/Grid";
|
||||||
import Card from '@material-ui/core/Card';
|
import Card from "@material-ui/core/Card";
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from "@material-ui/core/CardContent";
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
|
|
||||||
// component
|
// component
|
||||||
@ -31,7 +31,7 @@ class Home extends Component {
|
|||||||
console.log(res.data);
|
console.log(res.data);
|
||||||
this.setState({
|
this.setState({
|
||||||
posts: res.data
|
posts: res.data
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err));
|
.catch(err => console.log(err));
|
||||||
}
|
}
|
||||||
@ -41,17 +41,22 @@ class Home extends Component {
|
|||||||
let authenticated = this.props.user.authenticated;
|
let authenticated = this.props.user.authenticated;
|
||||||
let username = this.props.user.credentials.handle;
|
let username = this.props.user.credentials.handle;
|
||||||
let postMarkup = this.state.posts ? (
|
let postMarkup = this.state.posts ? (
|
||||||
this.state.posts.map(post =>
|
this.state.posts.map(post => (
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography>
|
<Typography>
|
||||||
{
|
{this.state.imageUrl ? (
|
||||||
this.state.imageUrl ? (<img src={this.state.imageUrl} height="250" width="250" />) :
|
<img src={this.state.imageUrl} height="250" width="250" />
|
||||||
(<img src={noImage} height="50" width="50"/>)
|
) : (
|
||||||
}
|
<img src={noImage} height="50" width="50" />
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="h7">
|
||||||
|
<b>{post.userHandle}</b>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" color={"textSecondary"}>
|
||||||
|
{post.createdAt}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="h7"><b>{post.userHandle}</b></Typography>
|
|
||||||
<Typography variant="body2" color={"textSecondary"}>{post.createdAt}</Typography>
|
|
||||||
<br />
|
<br />
|
||||||
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
|
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
|
||||||
<Typography variant="body2">{post.quoteBody}</Typography>
|
<Typography variant="body2">{post.quoteBody}</Typography>
|
||||||
@ -65,11 +70,12 @@ class Home extends Component {
|
|||||||
<Quote microblog = {post.postId}></Quote>
|
<Quote microblog = {post.postId}></Quote>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
))
|
||||||
) : (<p>My Posts</p>);
|
) : (
|
||||||
|
<p>Loading post...</p>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return authenticated ? (
|
||||||
authenticated ?
|
|
||||||
<Grid container spacing={16}>
|
<Grid container spacing={16}>
|
||||||
<Grid item sm={4} xs={8}>
|
<Grid item sm={4} xs={8}>
|
||||||
<Writing_Microblogs />
|
<Writing_Microblogs />
|
||||||
@ -77,26 +83,32 @@ class Home extends Component {
|
|||||||
<Grid item sm={4} xs={8}>
|
<Grid item sm={4} xs={8}>
|
||||||
{postMarkup}
|
{postMarkup}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
:
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<img src={logo} className="app-logo" alt="logo" />
|
<img src={logo} className="app-logo" alt="logo" />
|
||||||
<br/><br/>
|
<br />
|
||||||
<b>Welcome to Twistter!</b>
|
<br />
|
||||||
<br/><br/>
|
<b>Welcome to Twistter!</b>
|
||||||
<b>See the most interesting topics people are following right now.</b>
|
<br />
|
||||||
|
<br />
|
||||||
|
<b>See the most interesting topics people are following right now.</b>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/><br/><br/><br/>
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b>Join today or sign in if you already have an account.</b>
|
<b>Join today or sign in if you already have an account.</b>
|
||||||
<br/><br/>
|
<br />
|
||||||
|
<br />
|
||||||
<form action="./signup">
|
<form action="./signup">
|
||||||
<button className="authButtons signup">Sign up</button>
|
<button className="authButtons signup">Sign up</button>
|
||||||
</form>
|
</form>
|
||||||
<br/>
|
<br />
|
||||||
<form action="./login">
|
<form action="./login">
|
||||||
<button className="authButtons login">Sign in</button>
|
<button className="authButtons login">Sign in</button>
|
||||||
</form>
|
</form>
|
||||||
@ -106,7 +118,6 @@ class Home extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Quote extends Component {
|
class Quote extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -319,11 +330,11 @@ class Like extends Component {
|
|||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
user: state.user
|
user: state.user
|
||||||
})
|
});
|
||||||
|
|
||||||
Home.propTypes = {
|
Home.propTypes = {
|
||||||
user: PropTypes.object.isRequired
|
user: PropTypes.object.isRequired
|
||||||
}
|
};
|
||||||
|
|
||||||
Like.propTypes = {
|
Like.propTypes = {
|
||||||
user: PropTypes.object.isRequired
|
user: PropTypes.object.isRequired
|
||||||
@ -333,4 +344,4 @@ Quote.propTypes = {
|
|||||||
user: PropTypes.object.isRequired
|
user: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps)(Home, Like, Quote);
|
export default connect(mapStateToProps)(Home, Like, Quote);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user