Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import AuthService from '../services/auth/Auth';
  4.  
  5. class LoginPage extends React.Component {
  6. constructor(props) {
  7. super(props);
  8.  
  9. this.state = {
  10. email: '',
  11. password: 'test',
  12. submitted: false
  13. }
  14.  
  15. this.handleSubmit = this.handleSubmit.bind(this);
  16. this.handleChange = this.handleChange.bind(this);
  17. }
  18. handleChange(e) {
  19. const { name, value } = e.target;
  20. this.setState({ [name]: value });
  21. }
  22.  
  23. handleSubmit(event) {
  24. event.preventDefault();
  25. this.setState({ submitted: true });
  26. const { username, password } = this.state;
  27. AuthService.login(username, password);
  28. }
  29.  
  30. render() {
  31. return (
  32. <div>
  33. <form onSubmit={this.handleSubmit}>
  34. <div className="form-group">
  35. <label htmlFor="email">Email address</label>
  36. <input type="email" className="form-control" id="email" name="email" aria-describedby="emailHelp"
  37. placeholder="Enter email" value={this.state.email} onChange={this.handleChange} required />
  38. <small id="emailHelp" className="form-text text-muted">We'll never share your email with anyone else.</small>
  39. </div>
  40. <div className="form-group">
  41. <label htmlFor="password">Password</label>
  42. <input type="password" className="form-control" id="password" name="password" placeholder="Password"
  43. value={this.state.password} onChange={this.handleChange} required />
  44. </div>
  45. <div className="form-check">
  46. <input type="checkbox" className="form-check-input" id="rememberMe" />
  47. <label className="form-check-label" htmlFor="rememberMe">Remember me</label>
  48. </div>
  49. <button type="submit" className="btn btn-primary">Login</button>
  50. <a href="/register">Sign in</a>
  51. </form>
  52. </div>
  53. );
  54. }
  55. }
  56. function mapStateToProps(state) {
  57.  
  58. }
  59.  
  60. const connectedLoginPage = connect(mapStateToProps)(LoginPage);
  61. export { connectedLoginPage as LoginPage };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement