mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 18:28:47 +00:00
Fixing up profile UI
This commit is contained in:
parent
f602b8251f
commit
3d875e2bde
@ -3,122 +3,200 @@ import React, { Component } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
//import '../App.css';
|
//import '../App.css';
|
||||||
|
// Material-UI
|
||||||
|
import withStyles from '@material-ui/core/styles/withStyles';
|
||||||
import { makeStyles, styled } from '@material-ui/core/styles';
|
import { makeStyles, styled } from '@material-ui/core/styles';
|
||||||
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 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 Button from '@material-ui/core/Button';
|
||||||
|
import GridList from '@material-ui/core/GridList';
|
||||||
|
import GridListTile from '@material-ui/core/GridListTile';
|
||||||
|
import GridListTileBar from '@material-ui/core/GridListTileBar';
|
||||||
|
|
||||||
// component
|
// component
|
||||||
import Userline from '../Userline';
|
import Userline from '../Userline';
|
||||||
import noImage from '../images/no-img.png';
|
import noImage from '../images/no-img.png';
|
||||||
|
import Paper from '@material-ui/core/Paper';
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
button: {
|
||||||
|
positon: 'relative',
|
||||||
|
float: 'left',
|
||||||
|
marginLeft: 30,
|
||||||
|
marginTop: 15
|
||||||
|
},
|
||||||
|
paper: {
|
||||||
|
// marginLeft: "10%",
|
||||||
|
// marginRight: "10%"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const MyChip = styled(Chip)({
|
const MyChip = styled(Chip)({
|
||||||
margin: 2,
|
margin: 2,
|
||||||
color: 'primary'
|
color: 'primary'
|
||||||
});
|
});
|
||||||
|
|
||||||
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) => {
|
||||||
alert(`Delete topic: ${topic}!`);
|
alert(`Delete topic: ${topic}!`);
|
||||||
}
|
};
|
||||||
|
|
||||||
handleAddCircle = () => {
|
handleAddCircle = () => {
|
||||||
axios.post('/putTopic', {
|
axios
|
||||||
topic: this.state.newTopic
|
.post('/putTopic', {
|
||||||
})
|
topic: this.state.newTopic
|
||||||
.then(function () {
|
})
|
||||||
location.reload();
|
.then(function() {
|
||||||
})
|
location.reload();
|
||||||
.catch(function (err) {
|
})
|
||||||
console.log(err);
|
.catch(function(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
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.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));
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const classes = this.props;
|
const { classes } = this.props;
|
||||||
let profileMarkup = this.state.profile ? (
|
let profileMarkup = this.state.profile ? (
|
||||||
<p>
|
<p>
|
||||||
<Typography variant='h5'>{this.state.profile}</Typography>
|
<Typography variant="h5">{this.state.profile}</Typography>
|
||||||
</p>) : (<p>loading username...</p>);
|
</p>
|
||||||
|
) : (
|
||||||
|
<p>loading username...</p>
|
||||||
|
);
|
||||||
|
|
||||||
|
let topicsMarkup = this.state.topics ? (
|
||||||
|
this.state.topics.map((topic) => (
|
||||||
|
<MyChip
|
||||||
|
label={{ topic }.topic.topic}
|
||||||
|
key={{ topic }.topic.topicId}
|
||||||
|
onDelete={(topic) => this.handleDelete(topic)}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<p> loading topics...</p>
|
||||||
|
);
|
||||||
|
|
||||||
let topicsMarkup = this.state.topics ? (
|
let imageMarkup = this.state.imageUrl ? (
|
||||||
this.state.topics.map(topic => <MyChip
|
<img src={this.state.imageUrl} height="250" width="250" />
|
||||||
label={{topic}.topic.topic}
|
) : (
|
||||||
key={{topic}.topic.topicId}
|
<img src={noImage} />
|
||||||
onDelete={ (topic) => this.handleDelete(topic)}/>)
|
);
|
||||||
) : (<p> loading topics...</p>);
|
|
||||||
|
|
||||||
let imageMarkup = this.state.imageUrl ? (
|
// FIX: This needs to check if user's profile page being displayed
|
||||||
<img
|
// is the same as the user who is logged in
|
||||||
src={this.state.imageUrl}
|
// Can't check for that right now, because this page is always
|
||||||
height="250"
|
// showing the logged in users profile, instead of retreiving the
|
||||||
width="250"
|
// profile based on the URL entered
|
||||||
/>
|
let editButtonMarkup = true ? (
|
||||||
) : (<img src={noImage}/>);
|
<Button className={classes.button} variant="outlined" color="primary">
|
||||||
|
Edit Profile
|
||||||
|
</Button>
|
||||||
|
) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container spacing={16}>
|
// <Grid container spacing={16}>
|
||||||
<Grid item sm={8} xs={12}>
|
// <Grid item sm={8} xs={12}>
|
||||||
<p>Post</p>
|
// <p>Posts go here</p>
|
||||||
</Grid>
|
// </Grid>
|
||||||
<Grid item sm={4} xs={12}>
|
// <Grid item sm={4} xs={12}>
|
||||||
{imageMarkup}
|
// {editButtonMarkup}
|
||||||
{profileMarkup}
|
// {imageMarkup}
|
||||||
{topicsMarkup}
|
// {profileMarkup}
|
||||||
<TextField
|
// {topicsMarkup}
|
||||||
id="newTopic"
|
// <TextField
|
||||||
label="new topic"
|
// id="newTopic"
|
||||||
defaultValue=""
|
// label="new topic"
|
||||||
margin="normal"
|
// defaultValue=""
|
||||||
variant="outlined"
|
// margin="normal"
|
||||||
value={this.state.newTopic}
|
// variant="outlined"
|
||||||
onChange={ (event) => this.handleChange(event)}
|
// value={this.state.newTopic}
|
||||||
/>
|
// onChange={ (event) => this.handleChange(event)}
|
||||||
<AddCircle
|
// />
|
||||||
color="primary"
|
// <AddCircle
|
||||||
clickable
|
// color="primary"
|
||||||
onClick={this.handleAddCircle}
|
// clickable
|
||||||
/>
|
// onClick={this.handleAddCircle}
|
||||||
</Grid>
|
// />
|
||||||
</Grid>
|
// </Grid>
|
||||||
);
|
// </Grid>
|
||||||
}
|
<div>
|
||||||
|
{/* <Paper className={classes.paper}> */}
|
||||||
|
|
||||||
|
<Grid container>
|
||||||
|
<Grid item sm>
|
||||||
|
{editButtonMarkup}
|
||||||
|
</Grid>
|
||||||
|
<Grid item sm>
|
||||||
|
<Grid container direction="column">
|
||||||
|
<Grid item sm>
|
||||||
|
{imageMarkup}
|
||||||
|
{profileMarkup}
|
||||||
|
{topicsMarkup}
|
||||||
|
<TextField
|
||||||
|
id="newTopic"
|
||||||
|
label="new topic"
|
||||||
|
defaultValue=""
|
||||||
|
margin="normal"
|
||||||
|
variant="outlined"
|
||||||
|
value={this.state.newTopic}
|
||||||
|
onChange={(event) => this.handleChange(event)}
|
||||||
|
/>
|
||||||
|
<AddCircle color="primary" clickable onClick={this.handleAddCircle} />
|
||||||
|
</Grid>
|
||||||
|
<Grid item sm>
|
||||||
|
<p>posts here</p>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<Grid item sm />
|
||||||
|
</Grid>
|
||||||
|
{/* </Paper> */}
|
||||||
|
|
||||||
|
{/* <GridList>
|
||||||
|
<GridListTile key="subheader">
|
||||||
|
<p>Posts go here</p>
|
||||||
|
</GridListTile>
|
||||||
|
</GridList> */}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default user;
|
// export default user;
|
||||||
|
export default withStyles(styles)(user);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user