aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib/url.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-06-28 14:04:27 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-06-28 14:04:27 +0200
commitecc6e06e92f23b16817985e87b2e997b754f527d (patch)
tree38eed15bfb8fe63113a8db7e71daf1229cb2425d /src/client/react/lib/url.js
parent9efc432e160b429a0643c38e28140bcf42af30a7 (diff)
Move setWeek to an action
Diffstat (limited to 'src/client/react/lib/url.js')
-rw-r--r--src/client/react/lib/url.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/client/react/lib/url.js b/src/client/react/lib/url.js
index fcd3e6a..752fec2 100644
--- a/src/client/react/lib/url.js
+++ b/src/client/react/lib/url.js
@@ -70,3 +70,21 @@ export function makeSetWeek(history) {
history.push(`${history.location.pathname}?${query}`);
};
}
+
+export function makeUpdatePathname(history) {
+ return function updatePathname(pathname) {
+ const query = history.location.search;
+ history.push(`/${pathname}${query}`);
+ };
+}
+
+export function makeUpdateQuery(history) {
+ return function updateQuery(newQuery) {
+ const query = queryString.stringify({
+ ...queryString.parse(history.location.search),
+ ...newQuery,
+ });
+
+ history.push(`${history.location.pathname}?${query}`);
+ };
+}