Skip to content

Commit

Permalink
Merge pull request #4 from abraha2d/dev
Browse files Browse the repository at this point in the history
Release v0.2.0
  • Loading branch information
abraha2d committed Aug 11, 2018
2 parents b0e4c7f + c8d742f commit d1c3d30
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 18 deletions.
17 changes: 9 additions & 8 deletions src/containers/HomePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { compose } from "redux";
import { createStructuredSelector } from "reselect";
import { Route, Switch } from "react-router-dom";
import { push } from "connected-react-router/immutable";

Expand All @@ -33,9 +34,13 @@ import {
Settings as SettingsIcon
} from "@material-ui/icons";

import makeSelectAuth from "containers/LoginPage/selectors";

import Subscriptions from "containers/Subscriptions";
import ProfilePage from "containers/ProfilePage";
import Settings from "containers/Settings";
import NotFoundPage from "containers/NotFoundPage";

import LogoutButton from "containers/LoginPage/ConnectedLogoutButton";
import UserListItem from "components/UserListItem";

Expand Down Expand Up @@ -182,6 +187,7 @@ class HomePage extends React.PureComponent {
<div className={classes.toolbar} />
<Switch>
<Route exact path="/" component={Subscriptions} />
<Route exact path="/profile" component={ProfilePage} />
<Route exact path="/settings" component={Settings} />
<Route component={NotFoundPage} />
</Switch>
Expand All @@ -198,14 +204,9 @@ HomePage.propTypes = {
auth: PropTypes.object
};

const mapStateToProps = state => {
let location = state.getIn(["router", "location"]).toJS();
if (location.location) {
location = location.location;
}
const auth = state.get("auth").toJS();
return { location, auth };
};
const mapStateToProps = createStructuredSelector({
auth: makeSelectAuth()
});

const withConnect = connect(mapStateToProps);

Expand Down
11 changes: 1 addition & 10 deletions src/containers/NotFoundPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import React from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";

import { Typography } from "@material-ui/core";

Expand All @@ -23,12 +22,4 @@ NotFoundPage.propTypes = {
location: PropTypes.object.isRequired
};

const mapStateToProps = state => {
let location = state.getIn(["router", "location"]).toJS();
if (location.location) {
location = location.location;
}
return { location };
};

export default connect(mapStateToProps)(NotFoundPage);
export default NotFoundPage;
110 changes: 110 additions & 0 deletions src/containers/ProfilePage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/**
*
* ProfilePage
*
*/

import React from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { compose } from "redux";
import { createStructuredSelector } from "reselect";

import {
Avatar,
Button,
TextField,
Typography,
withStyles
} from "@material-ui/core";

import makeSelectAuth from "containers/LoginPage/selectors";

const styles = theme => ({
container: {
display: "flex",
flexDirection: "column"
},
centerAvatar: {
width: "96px",
height: "96px",
alignSelf: "center"
},
content: {
padding: `${theme.spacing.unit}px`
},
actions: {
padding: `${theme.spacing.unit}px`,
textAlign: "end"
}
});

export class ProfilePage extends React.PureComponent {
constructor(props) {
super(props);
this.state = { ...props.auth.user };
}

handleChange = name => event => {
const value = event.target.value;
this.setState({ [name]: value });
};

handleSave = event => {
event.preventDefault();
};

render() {
const { classes } = this.props;
return (
<div className={classes.container}>
<Typography variant="title">Profile</Typography>
<Avatar
src={this.props.auth.user.picture}
className={classes.centerAvatar}
/>
<form onSubmit={this.handleSave}>
<div className={classes.content}>
<TextField
label="Name"
required
fullWidth
margin="dense"
value={this.state.name}
onChange={this.handleChange("name")}
/>
<TextField
label="Email"
type="email"
required
fullWidth
margin="dense"
value={this.state.email}
onChange={this.handleChange("email")}
/>
</div>
<div className={classes.actions}>
<Button variant="contained" color="primary" type="submit">
Save
</Button>
</div>
</form>
</div>
);
}
}

ProfilePage.propTypes = {
auth: PropTypes.object.isRequired
};

const mapStateToProps = createStructuredSelector({
auth: makeSelectAuth()
});

const withConnect = connect(mapStateToProps);

export default compose(
withConnect,
withStyles(styles)
)(ProfilePage);

0 comments on commit d1c3d30

Please sign in to comment.