aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/react/lib')
-rw-r--r--src/client/react/lib/getHistory.js12
-rw-r--r--src/client/react/lib/url.js18
2 files changed, 24 insertions, 6 deletions
diff --git a/src/client/react/lib/getHistory.js b/src/client/react/lib/getHistory.js
index 642a9a8..5fef902 100644
--- a/src/client/react/lib/getHistory.js
+++ b/src/client/react/lib/getHistory.js
@@ -1,22 +1,22 @@
import {
- makeSetUser,
- makeSetWeek,
weekFromLocation,
userFromLocation,
+ makeUpdatePathname,
+ makeUpdateQuery,
} from './url';
export default function makeGetHistory(history) {
return function getHistory() {
const user = userFromLocation(history.location);
const week = weekFromLocation(history.location);
- const setUser = makeSetUser(history);
- const setWeek = makeSetWeek(history);
+ const updatePathname = makeUpdatePathname(history);
+ const updateQuery = makeUpdateQuery(history);
return {
user,
week,
- setUser,
- setWeek,
+ updatePathname,
+ updateQuery,
};
};
}
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}`);
+ };
+}