Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { connect } from 'react-redux';
- import AuthService from '../services/auth/Auth';
- class LoginPage extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- email: '',
- password: 'test',
- submitted: false
- }
- this.handleSubmit = this.handleSubmit.bind(this);
- this.handleChange = this.handleChange.bind(this);
- }
- handleChange(e) {
- const { name, value } = e.target;
- this.setState({ [name]: value });
- }
- handleSubmit(event) {
- event.preventDefault();
- this.setState({ submitted: true });
- const { username, password } = this.state;
- AuthService.login(username, password);
- }
- render() {
- return (
- <div>
- <form onSubmit={this.handleSubmit}>
- <div className="form-group">
- <label htmlFor="email">Email address</label>
- <input type="email" className="form-control" id="email" name="email" aria-describedby="emailHelp"
- placeholder="Enter email" value={this.state.email} onChange={this.handleChange} required />
- <small id="emailHelp" className="form-text text-muted">We'll never share your email with anyone else.</small>
- </div>
- <div className="form-group">
- <label htmlFor="password">Password</label>
- <input type="password" className="form-control" id="password" name="password" placeholder="Password"
- value={this.state.password} onChange={this.handleChange} required />
- </div>
- <div className="form-check">
- <input type="checkbox" className="form-check-input" id="rememberMe" />
- <label className="form-check-label" htmlFor="rememberMe">Remember me</label>
- </div>
- <button type="submit" className="btn btn-primary">Login</button>
- <a href="/register">Sign in</a>
- </form>
- </div>
- );
- }
- }
- function mapStateToProps(state) {
- }
- const connectedLoginPage = connect(mapStateToProps)(LoginPage);
- export { connectedLoginPage as LoginPage };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement