aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-12-10 19:24:53 +0100
committerNoah Loomans <noahloomans@gmail.com>2017-12-10 19:24:53 +0100
commitddccdcf22bb5008022e93c4789311fb2da95d7cf (patch)
tree154a5398051e98e5bec149444cbbac84c9afc29f
parent088f0a2c1ca5d305d83ff001650cca729643c718 (diff)
Refactor state names
-rw-r--r--src/client/react/components/container/Search.js4
-rw-r--r--src/client/react/reducers/search.js10
2 files changed, 8 insertions, 6 deletions
diff --git a/src/client/react/components/container/Search.js b/src/client/react/components/container/Search.js
index 70b3685..f17a517 100644
--- a/src/client/react/components/container/Search.js
+++ b/src/client/react/components/container/Search.js
@@ -3,8 +3,8 @@ import { inputChange, focusChange } from '../../actions/search';
import PresentationalSearch from '../presentational/Search';
const mapStateToProps = state => ({
- results: state.search.searchResults,
- value: state.search.searchInput,
+ results: state.search.results,
+ value: state.search.input,
hasFocus: state.search.hasFocus,
exactMatch: state.search.exactMatch,
});
diff --git a/src/client/react/reducers/search.js b/src/client/react/reducers/search.js
index 5d8fee5..52f3b4e 100644
--- a/src/client/react/reducers/search.js
+++ b/src/client/react/reducers/search.js
@@ -2,8 +2,8 @@
import fuzzy from 'fuzzy';
const DEFAULT_STATE = {
- searchInput: '',
- searchResults: [
+ input: '',
+ results: [
{ type: 's', value: '18561' },
],
exactMatch: null,
@@ -31,6 +31,8 @@ const search = (state = DEFAULT_STATE, action) => {
let results = getSearchResults(action.typedValue);
let exactMatch = null;
+ // Is the typed value exactly the same as the first result? Then show the
+ // appropiate icon instead of the generic search icon.
if ((results.length > 0) && (action.typedValue === results[0].value)) {
[exactMatch] = results;
results = results.splice(1);
@@ -38,8 +40,8 @@ const search = (state = DEFAULT_STATE, action) => {
return {
...state,
- searchInput: action.typedValue,
- searchResults: results,
+ input: action.typedValue,
+ results,
exactMatch,
};
}