From 50671ed027f874992ac50cfb21e123f579440737 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Mon, 19 Feb 2018 20:24:37 +0100 Subject: Remove action creators --- src/client/react/components/container/Search.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/client/react/components/container/Search.js') diff --git a/src/client/react/components/container/Search.js b/src/client/react/components/container/Search.js index b84502c..1c4ca4f 100644 --- a/src/client/react/components/container/Search.js +++ b/src/client/react/components/container/Search.js @@ -27,7 +27,6 @@ import { withRouter } from 'react-router-dom'; import SearchIcon from 'react-icons/lib/md/search'; import { userFromMatch } from '../../lib/url'; -import { setUser, inputChange, changeSelectedResult } from '../../actions/search'; import users from '../../users'; import Results from './Results'; @@ -65,13 +64,13 @@ class Search extends React.Component { componentDidMount() { const urlUser = userFromMatch(this.props.match); - this.props.dispatch(setUser(urlUser)); + this.props.dispatch({ type: 'SEARCH/SET_USERS', urlUser }); } componentWillReceiveProps(nextProps) { if (nextProps.match !== this.props.match) { const urlUser = userFromMatch(nextProps.match); - this.props.dispatch(setUser(urlUser)); + this.props.dispatch({ type: 'SEARCH/SET_USERS', urlUser }); } } @@ -94,17 +93,17 @@ class Search extends React.Component { switch (event.key) { case 'ArrowUp': event.preventDefault(); - this.props.dispatch(changeSelectedResult(-1)); + this.props.dispatch({ type: 'SEARCH/CHANGE_SELECTED_RESULT', relativeChange: -1 }); break; case 'ArrowDown': event.preventDefault(); - this.props.dispatch(changeSelectedResult(+1)); + this.props.dispatch({ type: 'SEARCH/CHANGE_SELECTED_RESULT', relativeChange: +1 }); break; case 'Escape': event.preventDefault(); - this.props.dispatch(setUser(urlUser)); + this.props.dispatch({ type: 'SEARCH/SET_USERS', urlUser }); break; case 'Enter': @@ -113,7 +112,7 @@ class Search extends React.Component { // EDGE CASE: The user is set if the user changes, but it doesn't // change if the result is already the one we are viewing. // Therefor, we need to dispatch the SET_USER command manually. - this.props.dispatch(setUser(urlUser)); + this.props.dispatch({ type: 'SEARCH/SET_USERS', urlUser }); } else if (result) { this.props.history.push(`/${result}`); } @@ -153,7 +152,7 @@ class Search extends React.Component { dispatch(inputChange(event.target.value))} + onChange={event => dispatch({ type: 'SEARCH/INPUT_CHANGE', searchText: event.target.value })} onKeyDown={this.onKeyDown} value={searchText} placeholder="Zoeken" -- cgit v1.1