aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/presentational
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-07-06 16:14:30 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-07-06 16:14:30 +0200
commitebb14ffc54670c8e2cbeba18eac238965eee4e81 (patch)
treed411ba6066a0ee4f38e85a6327456b9b4bc4b13b /src/client/react/components/presentational
parent9f935565ebe09444b7b576b0be986c6271baef39 (diff)
client: Simplify setUser
Diffstat (limited to 'src/client/react/components/presentational')
-rw-r--r--src/client/react/components/presentational/Results.js13
-rw-r--r--src/client/react/components/presentational/Search.js11
2 files changed, 13 insertions, 11 deletions
diff --git a/src/client/react/components/presentational/Results.js b/src/client/react/components/presentational/Results.js
index 173c644..4abd507 100644
--- a/src/client/react/components/presentational/Results.js
+++ b/src/client/react/components/presentational/Results.js
@@ -27,34 +27,35 @@ import './Results.scss';
class Results extends React.Component {
static propTypes = {
- results: PropTypes.arrayOf(PropTypes.string).isRequired,
+ results: PropTypes.arrayOf(PropTypes.string),
selectedResult: PropTypes.string,
- isExactMatch: PropTypes.bool.isRequired,
setUser: PropTypes.func.isRequired,
};
static defaultProps = {
selectedResult: null,
+ results: [],
};
render() {
const {
results,
selectedResult,
- isExactMatch,
setUser,
} = this.props;
+ const hasResults = results.length > 0;
+
return (
<div
className={classnames('Results', {
- hasResults: !isExactMatch && results.length > 0,
+ hasResults,
})}
style={{
- minHeight: isExactMatch ? 0 : results.length * 54,
+ minHeight: hasResults ? results.length * 54 : 0,
}}
>
- {!isExactMatch && results.map(userId => (
+ {results.map(userId => (
<Result
key={userId}
userId={userId}
diff --git a/src/client/react/components/presentational/Search.js b/src/client/react/components/presentational/Search.js
index c39b441..e7f49d6 100644
--- a/src/client/react/components/presentational/Search.js
+++ b/src/client/react/components/presentational/Search.js
@@ -37,8 +37,9 @@ class Search extends React.Component {
selectedUser: PropTypes.string,
searchText: PropTypes.string.isRequired,
isExactMatch: PropTypes.bool.isRequired,
- onInputChange: PropTypes.func.isRequired,
+
setUser: PropTypes.func.isRequired,
+ changeInput: PropTypes.func.isRequired,
changeSelectedUser: PropTypes.func.isRequired,
};
@@ -106,9 +107,9 @@ class Search extends React.Component {
render() {
const {
searchText,
- selectedUser,
+ currentUser,
isExactMatch,
- onInputChange,
+ changeInput,
} = this.props;
const {
@@ -121,13 +122,13 @@ class Search extends React.Component {
<div className="inputWrapper">
<div className="iconWrapper">
<IconFromUserType
- userType={isExactMatch ? users.byId[selectedUser].type : null}
+ userType={isExactMatch ? users.byId[currentUser].type : null}
defaultIcon={<SearchIcon />}
/>
</div>
<input
id="searchInput"
- onChange={event => onInputChange(event.target.value)}
+ onChange={event => changeInput(event.target.value)}
onKeyDown={event => this.handleKeyDown(event)}
value={searchText}
placeholder="Zoeken"