aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-03-20 16:51:59 +0100
committerNoah Loomans <noahloomans@gmail.com>2018-03-20 16:51:59 +0100
commit6ebb626a4beb1d47750c944c771e4f5487fb9ce4 (patch)
tree36c52c98bd11942c61cf436ad522e4d7702d0f4a /src
parente0ef8b7bca99692357a1d2f476b73124ff8406ac (diff)
Use setUser and setWeek everywhere
Diffstat (limited to 'src')
-rw-r--r--src/client/react/components/container/Results.js5
-rw-r--r--src/client/react/components/container/Search.js5
-rw-r--r--src/client/react/components/container/WeekSelector.js12
3 files changed, 12 insertions, 10 deletions
diff --git a/src/client/react/components/container/Results.js b/src/client/react/components/container/Results.js
index 5434eb4..4fc9987 100644
--- a/src/client/react/components/container/Results.js
+++ b/src/client/react/components/container/Results.js
@@ -25,7 +25,7 @@ import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import users from '../../users';
-import { userFromMatch } from '../../lib/url';
+import { setUser, userFromMatch } from '../../lib/url';
import Result from '../presentational/Result';
class Results extends React.Component {
@@ -36,6 +36,7 @@ class Results extends React.Component {
// react-router
match: PropTypes.object.isRequired,
+ location: PropTypes.object.isRequired,
history: PropTypes.object.isRequired,
// redux
@@ -74,7 +75,7 @@ class Results extends React.Component {
// Therefor, we need to dispatch the SET_USER command manually.
this.props.dispatch({ type: 'SEARCH/SET_USER', user });
} else {
- this.props.history.push(`/${userId}`);
+ setUser(userId, this.props.location, this.props.history);
}
}}
/>
diff --git a/src/client/react/components/container/Search.js b/src/client/react/components/container/Search.js
index 9c67667..c968957 100644
--- a/src/client/react/components/container/Search.js
+++ b/src/client/react/components/container/Search.js
@@ -26,7 +26,7 @@ import { withRouter } from 'react-router-dom';
import SearchIcon from 'react-icons/lib/md/search';
-import { userFromMatch } from '../../lib/url';
+import { setUser, userFromMatch } from '../../lib/url';
import users from '../../users';
import Menu from './Menu';
@@ -41,6 +41,7 @@ class Search extends React.Component {
// react-router
match: PropTypes.object.isRequired,
+ location: PropTypes.object.isRequired,
history: PropTypes.object.isRequired,
// redux
@@ -115,7 +116,7 @@ class Search extends React.Component {
// Therefor, we need to dispatch the SET_USER command manually.
this.props.dispatch({ type: 'SEARCH/SET_USER', user: urlUser });
} else if (result) {
- this.props.history.push(`/${result}`);
+ setUser(result, this.props.location, this.props.history);
}
break;
diff --git a/src/client/react/components/container/WeekSelector.js b/src/client/react/components/container/WeekSelector.js
index 3109bb7..9a88af6 100644
--- a/src/client/react/components/container/WeekSelector.js
+++ b/src/client/react/components/container/WeekSelector.js
@@ -21,14 +21,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
-import queryString from 'query-string';
import { withRouter } from 'react-router-dom';
import ArrowBackIcon from 'react-icons/lib/md/arrow-back';
import ArrowForwardIcon from 'react-icons/lib/md/arrow-forward';
import purifyWeek from '../../lib/purifyWeek';
-import { weekFromLocation } from '../../lib/url';
+import { setWeek, weekFromLocation } from '../../lib/url';
class WeekSelector extends React.Component {
static propTypes = {
@@ -59,10 +58,11 @@ class WeekSelector extends React.Component {
const newWeek = purifyWeek(week + change);
const isCurrentWeek = moment().week() === newWeek;
- const query = queryString.stringify({
- week: isCurrentWeek ? undefined : newWeek,
- });
- this.props.history.push(`${this.props.location.pathname}?${query}`);
+ setWeek(
+ isCurrentWeek ? undefined : newWeek,
+ this.props.location,
+ this.props.history,
+ );
}
render() {