2020-11-09 12:17:51 -08:00
|
|
|
import { reduce } from 'lodash-es';
|
2019-08-31 20:51:14 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shorthand to reduce visual complexity of code below
|
|
|
|
*/
|
|
|
|
type QueryParam = Record<string, { refreshModel: true }>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For each given query param, creates an object with `refreshModel` set to true
|
|
|
|
* @param {Array<string>} [params=[]]
|
|
|
|
* @returns {Record<string, { refreshModel: true }>}
|
|
|
|
*/
|
|
|
|
export const refreshModelForQueryParams = (params: Array<string> = []): QueryParam =>
|
|
|
|
reduce(
|
|
|
|
params,
|
|
|
|
(queryParams: QueryParam, param: string): QueryParam => ({ ...queryParams, [param]: { refreshModel: true } }),
|
|
|
|
{}
|
|
|
|
);
|