Guest User

Untitled

a guest
Dec 15th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. // auth.js Page
  2. import React from "react";
  3. import withNavBar from "../src/withNavBar";
  4. import { withRouter } from "next/router";
  5. import { compose } from "redux";
  6. import { withStyles } from "@material-ui/core";
  7.  
  8. import TextField from "@material-ui/core/TextField";
  9. import Button from "@material-ui/core/Button";
  10.  
  11. const styles = {
  12. root: {
  13. flexGrow: 1,
  14. textAlign: "center"
  15. },
  16. textField: {
  17. width: 400
  18. }
  19. };
  20.  
  21. class Auth extends React.Component {
  22. // Create our initial state
  23. state = {
  24. email: "",
  25. password: ""
  26. };
  27.  
  28. // Handle changes from text fields
  29. handleChange = name => event => {
  30. this.setState({
  31. [name]: event.target.value
  32. });
  33. };
  34.  
  35. render() {
  36. // Parse out action telling us whether we should login or signup
  37. // from props
  38. const {
  39. router: {
  40. query: { action }
  41. },
  42. classes
  43. } = this.props;
  44.  
  45. return (
  46. <div className={classes.root}>
  47. <TextField
  48. id="standard-name"
  49. label="Email"
  50. className={classes.textField}
  51. value={this.state.email}
  52. onChange={this.handleChange("email")}
  53. margin="normal"
  54. />
  55. <br />
  56. <TextField
  57. id="standard-name"
  58. label="Password"
  59. className={classes.textField}
  60. value={this.state.password}
  61. onChange={this.handleChange("password")}
  62. margin="normal"
  63. />
  64. <br />
  65.  
  66. <Button variant="contained" color="primary">
  67. {action}
  68. </Button>
  69. </div>
  70. );
  71. }
  72. }
  73.  
  74. // Composes functions from right to left
  75. export default compose(
  76. withNavBar,
  77. withStyles(styles),
  78. withRouter
  79. )(Auth);
Add Comment
Please, Sign In to add comment