From 2cac093369ecb965ddbef60e6dc2aa6e50f0e937 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Mon, 11 Dec 2017 20:36:51 +0100 Subject: Refactor Results out of Search --- src/client/react/components/container/Results.jsx | 15 +++++++++++++++ src/client/react/components/container/Search.jsx | 13 ++++--------- .../react/components/presentational/IconFromUserType.jsx | 2 +- src/client/react/components/presentational/Result.jsx | 2 ++ 4 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 src/client/react/components/container/Results.jsx (limited to 'src/client/react/components') diff --git a/src/client/react/components/container/Results.jsx b/src/client/react/components/container/Results.jsx new file mode 100644 index 0000000..04d1f84 --- /dev/null +++ b/src/client/react/components/container/Results.jsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import Result from '../presentational/Result'; + +const Results = (({ results }) => ( + results.map(user => ( + + )) +)); + +const mapStateToProps = state => ({ + results: state.search.results, +}); + +export default connect(mapStateToProps)(Results); diff --git a/src/client/react/components/container/Search.jsx b/src/client/react/components/container/Search.jsx index 7a2822f..7890423 100644 --- a/src/client/react/components/container/Search.jsx +++ b/src/client/react/components/container/Search.jsx @@ -7,8 +7,8 @@ import SearchIcon from 'react-icons/lib/md/search'; import { inputChange, focusChange } from '../../actions/search'; +import Results from './Results'; import IconFromUserType from '../presentational/IconFromUserType'; -import Result from '../presentational/Result'; const userShape = { value: PropTypes.string.isRequired, @@ -21,16 +21,14 @@ const Search = ({ onBlur, hasFocus, value, - results, exactMatch, }) => ( -
0 })}> +
- {/* Show the icon from the exact match if there is an exact match, otherwise show the search icon. */}
} + defaultIcon={} />
- {results.map(user => ( - - ))} +
); @@ -54,7 +50,6 @@ Search.propTypes = { onBlur: PropTypes.func.isRequired, hasFocus: PropTypes.bool.isRequired, value: PropTypes.string.isRequired, - results: PropTypes.arrayOf(PropTypes.shape(userShape)).isRequired, exactMatch: PropTypes.shape(userShape), }; diff --git a/src/client/react/components/presentational/IconFromUserType.jsx b/src/client/react/components/presentational/IconFromUserType.jsx index 6bd2a21..ee0e04b 100644 --- a/src/client/react/components/presentational/IconFromUserType.jsx +++ b/src/client/react/components/presentational/IconFromUserType.jsx @@ -26,7 +26,7 @@ const IconFromUserType = ({ userType, defaultIcon }) => { IconFromUserType.propTypes = { userType: PropTypes.string, - defaultIcon: PropTypes.react, + defaultIcon: PropTypes.element, }; IconFromUserType.defaultProps = { diff --git a/src/client/react/components/presentational/Result.jsx b/src/client/react/components/presentational/Result.jsx index 4876493..a4a0b8e 100644 --- a/src/client/react/components/presentational/Result.jsx +++ b/src/client/react/components/presentational/Result.jsx @@ -16,3 +16,5 @@ Result.propTypes = { type: PropTypes.string.isRequired, }).isRequired, }; + +export default Result; -- cgit v1.1