aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/utils.js')
-rw-r--r--frontend/src/utils.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/frontend/src/utils.js b/frontend/src/utils.js
index f333f0d..06414ac 100644
--- a/frontend/src/utils.js
+++ b/frontend/src/utils.js
@@ -146,3 +146,19 @@ export function downloadBlob(blob, fileName) {
a.click();
window.URL.revokeObjectURL(url);
}
+
+export function updateParams(urlParams, payload) {
+ const params = new URLSearchParams(urlParams.toString());
+ Object.entries(payload).forEach(([key, value]) => {
+ if (value == null) {
+ params.delete(key);
+ } else if (Array.isArray(value)) {
+ params.delete(key);
+ value.forEach(v => params.append(key, v));
+ } else {
+ params.set(key, value);
+ }
+ });
+
+ return params;
+}