{"size": 1371, "ext": "js", "max_stars_repo_path": "src/components/boards/BoardInput.js", "max_stars_repo_name": "agiletkiewicz/my-minimony-frontend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/boards/BoardInput.js", "max_issues_repo_name": "agiletkiewicz/my-minimony-frontend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/boards/BoardInput.js", "max_forks_repo_name": "agiletkiewicz/my-minimony-frontend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.421875, "max_line_length": 58, "alphanum_fraction": 0.5251641138}
import React, { Component } from 'react';
import Form from 'react-bootstrap/Form';
import Button from 'react-bootstrap/Button';
import FormControl from 'react-bootstrap/FormControl';
import { connect } from 'react-redux';
import { addBoard } from '../../actions/addBoard';

class BoardInput extends Component {
  constructor(props) {
    super(props);
    this.state = {
      title: '',
    };
  }

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

  handleSubmit = (event) => {
    event.preventDefault();
    this.props.addBoard(this.state);
    this.setState({
      title: '',
    });
  };

  render() {
    const { title } = this.state;

    return (
      <>
        <br />
        <h4>Add a new board</h4>
        <Form
          inline
          onSubmit={this.handleSubmit}
          className="justify-content-md-center"
        >
          <FormControl
            type="text"
            placeholder="title"
            className="mr-sm-2"
            name="title"
            value={title}
            onChange={this.handleChange}
          />
          <Button variant="outline-success" type="submit">
            Add
          </Button>
        </Form>
        <br />
        <br />
        <br />
      </>
    );
  }
}

export default connect(null, { addBoard })(BoardInput);
