From ecc6e06e92f23b16817985e87b2e997b754f527d Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Thu, 28 Jun 2018 14:04:27 +0200 Subject: Move setWeek to an action --- src/client/react/lib/url.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/client/react/lib/url.js') 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}`); + }; +} -- cgit v1.1