aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/container
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-02-19 20:24:37 +0100
committerNoah Loomans <noahloomans@gmail.com>2018-02-19 20:24:37 +0100
commit50671ed027f874992ac50cfb21e123f579440737 (patch)
tree6f03e9f18151c12777a6122593eec2be63247c84 /src/client/react/components/container
parent7250c51f716a050c105aae4e9f46d9736e108654 (diff)
Remove action creators
Diffstat (limited to 'src/client/react/components/container')
-rw-r--r--src/client/react/components/container/Results.js3
-rw-r--r--src/client/react/components/container/Search.js15
-rw-r--r--src/client/react/components/container/View.js24
3 files changed, 30 insertions, 12 deletions
diff --git a/src/client/react/components/container/Results.js b/src/client/react/components/container/Results.js
index b36abb2..0f08d7a 100644
--- a/src/client/react/components/container/Results.js
+++ b/src/client/react/components/container/Results.js
@@ -25,7 +25,6 @@ import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import users from '../../users';
-import { setUser } from '../../actions/search';
import { userFromMatch } from '../../lib/url';
import Result from '../presentational/Result';
@@ -73,7 +72,7 @@ class Results 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(user));
+ this.props.dispatch({ type: 'SEARCH/SET_USER', user });
} else {
this.props.history.push(`/${userId}`);
}
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 {
</div>
<input
id="search__input"
- onChange={event => dispatch(inputChange(event.target.value))}
+ onChange={event => dispatch({ type: 'SEARCH/INPUT_CHANGE', searchText: event.target.value })}
onKeyDown={this.onKeyDown}
value={searchText}
placeholder="Zoeken"
diff --git a/src/client/react/components/container/View.js b/src/client/react/components/container/View.js
index 938614e..28aaad3 100644
--- a/src/client/react/components/container/View.js
+++ b/src/client/react/components/container/View.js
@@ -24,7 +24,6 @@ import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { userFromMatch, weekFromLocation } from '../../lib/url';
-import { fetchSchedule } from '../../actions/view';
import extractSchedule from '../../lib/extractSchedule';
import Schedule from '../presentational/Schedule';
@@ -66,7 +65,28 @@ class View extends React.Component {
const schedule = extractSchedule(schedules, user, week);
if (schedule.state === 'NOT_REQUESTED') {
- dispatch(fetchSchedule(user, week));
+ fetch(`/get/${user}?week=${week}`).then(
+ // success
+ (r) => {
+ r.text().then((htmlStr) => {
+ dispatch({
+ type: 'VIEW/FETCH_SCHEDULE_SUCCESS',
+ user,
+ week,
+ htmlStr,
+ });
+ });
+ },
+
+ // error
+ () => {
+ dispatch({
+ type: 'VIEW/FETCH_SCHEDULE_FAILURE',
+ week,
+ user,
+ });
+ },
+ );
}
}