Fixing up profile UI

This commit is contained in:
Clayton Wilson 2019-10-28 23:25:12 -04:00
parent 903ea35662
commit 7cc8a3f11f

View File

@ -19,16 +19,36 @@ 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';
import withStyles from '@material-ui/core/styles/withStyles';
import GridList from '@material-ui/core/GridList';
import GridListTile from '@material-ui/core/GridListTile';
import GridListTileBar from '@material-ui/core/GridListTileBar';
import Paper from '@material-ui/core/Paper';
// component // component
import '../App.css'; import '../App.css';
import noImage from '../images/no-img.png'; 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 = {
button: {
positon: 'relative',
float: 'left',
marginLeft: 30,
marginTop: 15
},
paper: {
// marginLeft: "10%",
// marginRight: "10%"
}
};
class user extends Component { class user extends Component {
state = { state = {
profile: null, profile: null,
@ -70,18 +90,18 @@ class user extends Component {
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
}); });
@ -100,8 +120,8 @@ class user extends Component {
} }
render() { render() {
const { classes } = this.props;
let authenticated = this.props.user.authenticated; let authenticated = this.props.user.authenticated;
let classes = this.props;
let profileMarkup = this.state.profile ? ( let profileMarkup = this.state.profile ? (
<div> <div>
@ -149,66 +169,108 @@ class user extends Component {
) )
) : (<p>My Posts</p>); ) : (<p>My Posts</p>);
return ( // FIX: This needs to check if user's profile page being displayed
<Grid container spacing={24}> // is the same as the user who is logged in
<Grid item sm={4} xs={8}> // Can't check for that right now, because this page is always
{imageMarkup} // showing the logged in users profile, instead of retreiving the
{profileMarkup} // profile based on the URL entered
{topicsMarkup} let editButtonMarkup = true ? (
<TextField <Button className={classes.button} variant="outlined" color="primary">
id="newTopic" Edit Profile
label="new topic" </Button>
defaultValue="" ) : null;
margin="normal"
variant="outlined"
value={this.state.newTopic}
onChange={(event) => this.handleChange(event)}
/>
<AddCircle
color="primary"
clickable
onClick={this.handleAddCircle}
/>
<br />
<Grid container direction="column">
<Grid item>
{
authenticated &&
<Button
style={{width:150, marginBottom: 10, marginTop: 5}}
component={ Link }
to='/edit'
variant="outlined"
color="primary"
>
Edit Profile
</Button>}
</Grid>
<Grid item>
{
authenticated &&
this.state.profile === 'Admin' &&
<Button
style={{width:150}}
component={ Link }
variant="outlined"
color="primary"
to='/verify' return (
> // <Grid container spacing={24}>
Verify Users // <Grid item sm={4} xs={8}>
</Button>} // {imageMarkup}
</Grid> // {profileMarkup}
</Grid> // {topicsMarkup}
</Grid> // <TextField
<Grid item sm={4} xs={8}> // id="newTopic"
{postMarkup} // label="new topic"
</Grid> // defaultValue=""
<Grid item sm={4} xs={8}> // margin="normal"
<Writing_Microblogs /> // variant="outlined"
</Grid> // value={this.state.newTopic}
       // onChange={(event) => this.handleChange(event)}
</Grid> // />
// <AddCircle
// color="primary"
// clickable
// onClick={this.handleAddCircle}
// />
// <br />
// <Grid container direction="column">
// <Grid item>
// {
// authenticated &&
// <Button
// style={{width:150, marginBottom: 10, marginTop: 5}}
// component={ Link }
// to='/edit'
// variant="outlined"
// color="primary"
// >
// Edit Profile
// </Button>}
// </Grid>
// <Grid item>
// {
// authenticated &&
// this.state.profile === 'Admin' &&
// <Button
// style={{width:150}}
// component={ Link }
// variant="outlined"
// color="primary"
// to='/verify'
// >
// Verify Users
// </Button>}
// </Grid>
// </Grid>
// </Grid>
// <Grid item sm={4} xs={8}>
// {postMarkup}
// </Grid>
// <Grid item sm={4} xs={8}>
// <Writing_Microblogs />
// </Grid>
//       
// </Grid>
<div>
<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>
</div>
); );
} }
} }
@ -221,4 +283,4 @@ user.propTypes = {
user: PropTypes.object.isRequired user: PropTypes.object.isRequired
} }
export default connect(mapStateToProps)(user); export default connect(mapStateToProps)(withStyles(styles)(user));