|
@@ -23,11 +23,12 @@ export const PorterUrls = [
|
|
|
"jobs",
|
|
"jobs",
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+// TODO: consolidate with pushFiltered
|
|
|
export const pushQueryParams = (props: any, params: any) => {
|
|
export const pushQueryParams = (props: any, params: any) => {
|
|
|
let { location, history } = props;
|
|
let { location, history } = props;
|
|
|
const urlParams = new URLSearchParams(location.search);
|
|
const urlParams = new URLSearchParams(location.search);
|
|
|
Object.keys(params)?.forEach((key: string) => {
|
|
Object.keys(params)?.forEach((key: string) => {
|
|
|
- urlParams.set(key, params[key]);
|
|
|
|
|
|
|
+ params[key] && urlParams.set(key, params[key]);
|
|
|
});
|
|
});
|
|
|
history.push({
|
|
history.push({
|
|
|
pathname: location.pathname,
|
|
pathname: location.pathname,
|
|
@@ -38,7 +39,8 @@ export const pushQueryParams = (props: any, params: any) => {
|
|
|
export const pushFiltered = (
|
|
export const pushFiltered = (
|
|
|
props: any, // Props for retrieving history and location
|
|
props: any, // Props for retrieving history and location
|
|
|
pathname: string, // Path to redirect to
|
|
pathname: string, // Path to redirect to
|
|
|
- keys: string[] // Query params to preserve during redirect
|
|
|
|
|
|
|
+ keys: string[], // Query params to preserve during redirect
|
|
|
|
|
+ params?: any,
|
|
|
) => {
|
|
) => {
|
|
|
let { location, history } = props;
|
|
let { location, history } = props;
|
|
|
let urlParams = new URLSearchParams(location.search);
|
|
let urlParams = new URLSearchParams(location.search);
|
|
@@ -47,6 +49,9 @@ export const pushFiltered = (
|
|
|
let value = urlParams.get(key);
|
|
let value = urlParams.get(key);
|
|
|
value && newUrlParams.set(key, value);
|
|
value && newUrlParams.set(key, value);
|
|
|
});
|
|
});
|
|
|
|
|
+ params && Object.keys(params)?.forEach((key: string) => {
|
|
|
|
|
+ params[key] && newUrlParams.set(key, params[key]);
|
|
|
|
|
+ });
|
|
|
history.push({
|
|
history.push({
|
|
|
pathname,
|
|
pathname,
|
|
|
search: newUrlParams.toString(),
|
|
search: newUrlParams.toString(),
|