mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +00:00
Profile page kinda works on mobile
This commit is contained in:
parent
80670d054e
commit
6149e15b35
@ -6,16 +6,16 @@ import axios from 'axios';
|
|||||||
//import '../App.css';
|
//import '../App.css';
|
||||||
|
|
||||||
// Material UI and React Router
|
// Material UI and React Router
|
||||||
import { makeStyles, styled } from "@material-ui/core/styles";
|
import { makeStyles, styled } from '@material-ui/core/styles';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Card from "@material-ui/core/Card";
|
import Card from '@material-ui/core/Card';
|
||||||
import CardMedia from '@material-ui/core/CardMedia';
|
import CardMedia from '@material-ui/core/CardMedia';
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from '@material-ui/core/CardContent';
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
import Grid from "@material-ui/core/Grid";
|
import Grid from '@material-ui/core/Grid';
|
||||||
|
|
||||||
import Chip from "@material-ui/core/Chip";
|
import Chip from '@material-ui/core/Chip';
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from '@material-ui/core/Typography';
|
||||||
import AddCircle from '@material-ui/icons/AddCircle';
|
import AddCircle from '@material-ui/icons/AddCircle';
|
||||||
import TextField from '@material-ui/core/TextField';
|
import TextField from '@material-ui/core/TextField';
|
||||||
import VerifiedIcon from '@material-ui/icons/CheckSharp';
|
import VerifiedIcon from '@material-ui/icons/CheckSharp';
|
||||||
@ -32,159 +32,186 @@ import noImage from '../images/no-img.png';
|
|||||||
import Writing_Microblogs from '../Writing_Microblogs';
|
import Writing_Microblogs from '../Writing_Microblogs';
|
||||||
|
|
||||||
const MyChip = styled(Chip)({
|
const MyChip = styled(Chip)({
|
||||||
margin: 2,
|
margin: 2,
|
||||||
color: "primary"
|
color: 'primary'
|
||||||
});
|
});
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
button: {
|
button: {
|
||||||
positon: 'relative',
|
positon: 'relative',
|
||||||
float: 'left',
|
float: 'left',
|
||||||
marginLeft: 30,
|
marginLeft: 30,
|
||||||
marginTop: 20
|
marginTop: 20
|
||||||
},
|
},
|
||||||
paper: {
|
paper: {
|
||||||
// marginLeft: "10%",
|
// marginLeft: "10%",
|
||||||
// marginRight: "10%"
|
// marginRight: "10%"
|
||||||
},
|
},
|
||||||
profileImage: {
|
card: {
|
||||||
marginTop: 20
|
marginBottom: 10
|
||||||
},
|
},
|
||||||
topicsContainer: {
|
profileImage: {
|
||||||
border: "lightgray solid 1px",
|
marginTop: 20
|
||||||
marginTop: 20,
|
},
|
||||||
paddingTop: 10,
|
topicsContainer: {
|
||||||
paddingBottom: 10,
|
border: 'lightgray solid 1px',
|
||||||
height: 300
|
marginTop: 20,
|
||||||
},
|
paddingTop: 10,
|
||||||
addCircle: {
|
paddingBottom: 10,
|
||||||
width: 65,
|
height: 300
|
||||||
height: 65,
|
},
|
||||||
marginTop: 10
|
addCircle: {
|
||||||
}
|
width: 65,
|
||||||
|
height: 65,
|
||||||
|
marginTop: 10
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
marginBottom: 100
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class user extends Component {
|
class user extends Component {
|
||||||
state = {
|
state = {
|
||||||
profile: null,
|
profile: null,
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
topics: null,
|
topics: null,
|
||||||
newTopic: null
|
newTopic: null
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDelete = topic => {
|
handleDelete = (topic) => {
|
||||||
axios
|
axios
|
||||||
.delete(`/deleteTopic/${topic.id}`)
|
.delete(`/deleteTopic/${topic.id}`)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleAddCircle = () => {
|
handleAddCircle = () => {
|
||||||
axios
|
axios
|
||||||
.post("/putTopic", {
|
.post('/putTopic', {
|
||||||
topic: this.state.newTopic
|
topic: this.state.newTopic
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleChange(event) {
|
handleChange(event) {
|
||||||
this.setState({
|
this.setState({
|
||||||
newTopic: event.target.value
|
newTopic: event.target.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
axios
|
axios
|
||||||
.get("/user")
|
.get('/user')
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
profile: res.data.credentials.handle,
|
profile: res.data.credentials.handle,
|
||||||
imageUrl: res.data.credentials.imageUrl,
|
imageUrl: res.data.credentials.imageUrl,
|
||||||
verified: res.data.credentials.verified ? res.data.credentials.verified : false
|
verified: res.data.credentials.verified ? res.data.credentials.verified : false
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.get("/getAllTopics")
|
.get('/getAllTopics')
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
topics: res.data
|
topics: res.data
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.get("/getallPostsforUser")
|
.get('/getallPostsforUser')
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { classes } = this.props;
|
const { classes } = this.props;
|
||||||
let authenticated = this.props.user.authenticated;
|
let authenticated = this.props.user.authenticated;
|
||||||
|
|
||||||
let profileMarkup = this.state.profile ? (
|
let profileMarkup = this.state.profile ? (
|
||||||
<div>
|
<div>
|
||||||
<Typography variant='h5'>@{this.state.profile} {this.state.verified ? (<VerifiedIcon style={{fill: "#1397D5"}}/>): (null)}</Typography>
|
<Typography variant="h5" className={classes.username}>
|
||||||
</div>) : (<p>loading username...</p>);
|
@{this.state.profile} {this.state.verified ? <VerifiedIcon style={{ fill: '#1397D5' }} /> : null}
|
||||||
|
</Typography>
|
||||||
let topicsMarkup = this.state.topics ? (
|
</div>
|
||||||
this.state.topics.map(
|
) : (
|
||||||
topic => (
|
<p className={classes.username}>loading username...</p>
|
||||||
<MyChip
|
);
|
||||||
label={{ topic }.topic.topic}
|
|
||||||
key={{ topic }.topic.id}
|
|
||||||
onDelete={key => this.handleDelete(topic)}
|
|
||||||
/>
|
|
||||||
) // console.log({ topic }.topic.id)
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<p> loading topics...</p>
|
|
||||||
);
|
|
||||||
|
|
||||||
let imageMarkup = this.state.imageUrl ? (<img src={this.state.imageUrl} height="150" width="150" />) :
|
let topicsMarkup = this.state.topics ? (
|
||||||
(<img src={noImage} height="150" width="150"/>);
|
this.state.topics.map(
|
||||||
|
(topic) => (
|
||||||
|
<MyChip
|
||||||
|
label={{ topic }.topic.topic}
|
||||||
|
key={{ topic }.topic.id}
|
||||||
|
onDelete={(key) => this.handleDelete(topic)}
|
||||||
|
/>
|
||||||
|
) // console.log({ topic }.topic.id)
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<p> loading topics...</p>
|
||||||
|
);
|
||||||
|
|
||||||
let postMarkup = this.state.posts ? (
|
let imageMarkup = this.state.imageUrl ? (
|
||||||
this.state.posts.map(post =>
|
<img className={classes.profileImage} src={this.state.imageUrl} height="250" width="250" />
|
||||||
<Card>
|
) : (
|
||||||
<CardContent>
|
<img className={classes.profileImage} src={noImage} height="250" width="250" />
|
||||||
<Typography>
|
);
|
||||||
{
|
|
||||||
this.state.imageUrl ? (<img src={this.state.imageUrl} 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>
|
|
||||||
<br />
|
|
||||||
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
|
|
||||||
<Typography variant="body2">{post.body}</Typography>
|
|
||||||
<br />
|
|
||||||
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics}</Typography>
|
|
||||||
<br />
|
|
||||||
<Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount} Comments {post.commentCount}</Typography>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
)
|
|
||||||
) : (<p>My Posts</p>);
|
|
||||||
|
|
||||||
// FIX: This needs to check if user's profile page being displayed
|
let postMarkup = this.state.posts ? (
|
||||||
|
this.state.posts.map((post) => (
|
||||||
|
<Card className={classes.card}>
|
||||||
|
<CardContent>
|
||||||
|
<Typography>
|
||||||
|
{this.state.imageUrl ? (
|
||||||
|
<img src={this.state.imageUrl} 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>
|
||||||
|
<br />
|
||||||
|
<Typography variant="body1">
|
||||||
|
<b>{post.microBlogTitle}</b>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">{post.body}</Typography>
|
||||||
|
<br />
|
||||||
|
<Typography variant="body2">
|
||||||
|
<b>Topics:</b> {post.microBlogTopics}
|
||||||
|
</Typography>
|
||||||
|
<br />
|
||||||
|
<Typography variant="body2" color={'textSecondary'}>
|
||||||
|
Likes {post.likeCount} Comments {post.commentCount}
|
||||||
|
</Typography>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<p>My Posts</p>
|
||||||
|
);
|
||||||
|
|
||||||
|
// FIX: This needs to check if user's profile page being displayed
|
||||||
// is the same as the user who is logged in
|
// is the same as the user who is logged in
|
||||||
// Can't check for that right now, because this page is always
|
// Can't check for that right now, because this page is always
|
||||||
// showing the logged in users profile, instead of retreiving the
|
// showing the logged in users profile, instead of retreiving the
|
||||||
@ -195,59 +222,68 @@ class user extends Component {
|
|||||||
</Button>
|
</Button>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* <Paper className={classes.paper}> */}
|
{/* <Paper className={classes.paper}> */}
|
||||||
|
<Grid container direction="column">
|
||||||
<Grid container>
|
<Grid item>
|
||||||
<Grid item sm>
|
<Grid container>
|
||||||
{editButtonMarkup}
|
<Grid item sm>
|
||||||
</Grid>
|
{editButtonMarkup}
|
||||||
<Grid item sm>
|
</Grid>
|
||||||
<Grid container direction="column">
|
<Grid item sm>
|
||||||
<Grid item sm>
|
{/* <Grid container direction="column"> */}
|
||||||
{imageMarkup}
|
{/* <Grid item sm> */}
|
||||||
{profileMarkup}
|
{imageMarkup}
|
||||||
</Grid>
|
{profileMarkup}
|
||||||
<Grid item sm>
|
{/* </Grid> */}
|
||||||
{postMarkup}
|
{/* <Grid item sm> */}
|
||||||
</Grid>
|
{/* {postMarkup} */}
|
||||||
</Grid>
|
{/* </Grid> */}
|
||||||
</Grid>
|
{/* </Grid> */}
|
||||||
<Grid item sm>
|
</Grid>
|
||||||
<Container
|
<Grid item sm>
|
||||||
className={classes.topicsContainer}
|
<Container className={classes.topicsContainer} maxWidth="xs">
|
||||||
maxWidth="xs">
|
{topicsMarkup}
|
||||||
{topicsMarkup}
|
</Container>
|
||||||
</Container>
|
<TextField
|
||||||
<TextField
|
id="newTopic"
|
||||||
id="newTopic"
|
label="new topic"
|
||||||
label="new topic"
|
defaultValue=""
|
||||||
defaultValue=""
|
margin="normal"
|
||||||
margin="normal"
|
variant="outlined"
|
||||||
variant="outlined"
|
value={this.state.newTopic}
|
||||||
value={this.state.newTopic}
|
onChange={(event) => this.handleChange(event)}
|
||||||
onChange={(event) => this.handleChange(event)}
|
/>
|
||||||
/>
|
<AddCircle
|
||||||
<AddCircle
|
className={classes.addCircle}
|
||||||
className={classes.addCircle}
|
color="primary"
|
||||||
color="primary"
|
// iconStyle={classes.addCircle}
|
||||||
// iconStyle={classes.addCircle}
|
clickable
|
||||||
clickable
|
onClick={this.handleAddCircle}
|
||||||
onClick={this.handleAddCircle} />
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</Grid>
|
||||||
);
|
<Grid item>
|
||||||
}
|
<Grid container>
|
||||||
|
<Grid item sm />
|
||||||
|
<Grid item>{postMarkup}</Grid>
|
||||||
|
<Grid item sm />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
user: state.user
|
user: state.user
|
||||||
})
|
});
|
||||||
|
|
||||||
user.propTypes = {
|
user.propTypes = {
|
||||||
user: PropTypes.object.isRequired
|
user: PropTypes.object.isRequired
|
||||||
}
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withStyles(styles)(user));
|
export default connect(mapStateToProps)(withStyles(styles)(user));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user