{"size": 1004, "ext": "js", "max_stars_repo_path": "src/component/search/search.component.js", "max_stars_repo_name": "nbusuttil/electron-with-create-react-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/component/search/search.component.js", "max_issues_repo_name": "nbusuttil/electron-with-create-react-app", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/component/search/search.component.js", "max_forks_repo_name": "nbusuttil/electron-with-create-react-app", "max_forks_repo_forks_event_min_datetime": "2017-12-17T18:56:00.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-17T18:56:00.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 20.9166666667, "max_line_length": 78, "alphanum_fraction": 0.6015936255}
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import SearchIcons from '../../icons/search.svg';

class Search extends Component {
  constructor(props) {
    super(props);
    this.state = { search: { name: '' } };
  }

  handleInputChange = event => {
    event.preventDefault();

    const { searchPatientAction } = this.props;
    const { name, value } = event.target;

    const { search } = this.state;

    search[name] = value;

    searchPatientAction(search);
  };

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

    return (
      <div>
        <img className="icons icons--search" src={SearchIcons} alt="search" />
        <input
          type="text"
          placeholder="Rechercher un patient"
          name="name"
          value={search.name}
          onChange={this.handleInputChange}
        />
      </div>
    );
  }
}

Search.propTypes = {
  // eslint-disable-next-line
  searchPatientAction: PropTypes.func.isRequired,
};

export default Search;
