Guest User

Untitled

a guest
Jan 28th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { connect } from 'react-redux';
  4. import Container from 'react-bootstrap/lib/Container';
  5. import Row from 'react-bootstrap/lib/Row';
  6. import Col from 'react-bootstrap/lib/Col';
  7. import Form from 'react-bootstrap/lib/Form';
  8. import Button from 'react-bootstrap/lib/Button';
  9. import { login } from '../actions/auth';
  10.  
  11. class Login extends Component {
  12. static propTypes = {
  13. _login: PropTypes.func.isRequired,
  14. }
  15.  
  16. onSubmit = (e) => {
  17. e.preventDefault();
  18. const { username, password } = this.state;
  19. const { _login } = this.props;
  20. _login(username, password);
  21. }
  22.  
  23. render() {
  24. return (
  25. <Container fluid="True" style={{ height: '100vh' }}>
  26. <Row className="h-100 align-items-center">
  27. <Col md={{ span: 6, offset: 3 }} className="text-center">
  28. <Form onSubmit={this.onSubmit}>
  29. <Form.Group controlId="formBasicName">
  30. <Form.Label>Name</Form.Label>
  31. <Form.Control
  32. type="name"
  33. placeholder="Enter name"
  34. onChange={e => this.setState({ username: e.target.value })}
  35. />
  36. </Form.Group>
  37.  
  38. <Form.Group controlId="formBasicPassword">
  39. <Form.Label>Password</Form.Label>
  40. <Form.Control
  41. type="password"
  42. placeholder="Enter Password"
  43. onChange={e => this.setState({ password: e.target.value })}
  44. />
  45. </Form.Group>
  46. <Button variant="primary" type="submit">
  47. Login
  48. </Button>
  49. </Form>
  50. </Col>
  51. </Row>
  52. </Container>
  53. );
  54. }
  55. }
  56.  
  57. const mapDispatchToProps = dispatch => ({
  58. _login: (username, password) => {
  59. dispatch(login(username, password));
  60. },
  61. });
  62.  
  63. export default connect(null, mapDispatchToProps)(Login);
Add Comment
Please, Sign In to add comment