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>);
// FIX: This needs to check if user's profile page being displayed
// is the same as the user who is logged in
// Can't check for that right now, because this page is always
// showing the logged in users profile, instead of retreiving the
// profile based on the URL entered
let editButtonMarkup = true ? (
<Button className={classes.button} variant="outlined" color="primary">
Edit Profile
</Button>
) : null;
return ( return (
<Grid container spacing={24}> // <Grid container spacing={24}>
<Grid item sm={4} xs={8}> // <Grid item sm={4} xs={8}>
{imageMarkup} // {imageMarkup}
{profileMarkup} // {profileMarkup}
{topicsMarkup} // {topicsMarkup}
<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
color="primary" // color="primary"
clickable // clickable
onClick={this.handleAddCircle} // onClick={this.handleAddCircle}
/> // />
<br /> // <br />
<Grid container direction="column"> // <Grid container direction="column">
<Grid item> // <Grid item>
{ // {
authenticated && // authenticated &&
<Button // <Button
style={{width:150, marginBottom: 10, marginTop: 5}} // style={{width:150, marginBottom: 10, marginTop: 5}}
component={ Link } // component={ Link }
to='/edit' // to='/edit'
variant="outlined" // variant="outlined"
color="primary" // color="primary"
> // >
Edit Profile // Edit Profile
</Button>} // </Button>}
</Grid> // </Grid>
<Grid item> // <Grid item>
{ // {
authenticated && // authenticated &&
this.state.profile === 'Admin' && // this.state.profile === 'Admin' &&
<Button // <Button
style={{width:150}} // style={{width:150}}
component={ Link } // component={ Link }
variant="outlined" // variant="outlined"
color="primary" // color="primary"
to='/verify' // to='/verify'
> // >
Verify Users // Verify Users
</Button>} // </Button>}
</Grid> // </Grid>
</Grid> // </Grid>
</Grid> // </Grid>
<Grid item sm={4} xs={8}> // <Grid item sm={4} xs={8}>
{postMarkup} // {postMarkup}
</Grid> // </Grid>
<Grid item sm={4} xs={8}> // <Grid item sm={4} xs={8}>
<Writing_Microblogs /> // <Writing_Microblogs />
</Grid> // </Grid>
       //       
</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));