huridocs/uwazi

View on GitHub
app/react/Connections/components/SearchForm.js

Summary

Maintainability
A
0 mins
Test Coverage
D
60%
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import SearchInput from 'app/Layout/SearchInput';
import { search } from '../actions/actions';

export class SearchForm extends Component {
  render() {
    return (
      <SearchInput
        value={this.props.searchTerm}
        onChange={e => this.props.search(e.target.value, this.props.connectionType)}
      />
    );
  }
}

SearchForm.propTypes = {
  search: PropTypes.func,
  searchTerm: PropTypes.string,
  connectionType: PropTypes.string,
};

function mapStateToProps({ connections }) {
  return {
    searchTerm: connections.searchTerm,
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({ search }, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(SearchForm);