From dedf8025a547d698d9f2e62f0897493d61ffadd5 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Tue, 26 Jun 2018 22:25:55 +0200 Subject: Use mapStateToProps for router simplification --- src/client/react/lib/url.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/client/react/lib') diff --git a/src/client/react/lib/url.js b/src/client/react/lib/url.js index be09acf..c94383c 100644 --- a/src/client/react/lib/url.js +++ b/src/client/react/lib/url.js @@ -43,16 +43,20 @@ export function weekFromLocation(location) { return purifyWeek(parseInt(weekStr, 10)); } -export function setUser(userId, location, history) { - const query = location.search; - history.push(`/${userId}${query}`); +export function makeSetUser(location, history) { + return (userId) => { + const query = location.search; + history.push(`/${userId}${query}`); + }; } -export function setWeek(week, location, history) { - const query = queryString.stringify({ - ...queryString.parse(location.search), - week, - }); +export function makeSetWeek(location, history) { + return (week) => { + const query = queryString.stringify({ + ...queryString.parse(location.search), + week, + }); - history.push(`${location.pathname}?${query}`); + history.push(`${location.pathname}?${query}`); + }; } -- cgit v1.1