saleor-dashboard/testUtils/filters.ts
Jakub Majorek a7736e2bf9
Attach permission variables to all queries (#1000)
* [SALEOR-2190] Attach permission variables to all queries

* Fix TS linter issues

* Update package-lock
2021-03-09 09:44:09 +01:00

20 lines
534 B
TypeScript

import { IFilter } from "@saleor/components/Filter";
import clone from "lodash-es/clone";
export function getExistingKeys(o: {}): string[] {
return Object.keys(o).filter(key => o[key] !== undefined && o[key] !== null);
}
export function setFilterOptsStatus<T extends string>(
opts: IFilter<T>,
status: boolean
): IFilter<T> {
const newOpts = clone(opts);
for (const optName in opts) {
if (Object.prototype.hasOwnProperty.call(newOpts, optName)) {
newOpts[optName].active = status;
}
}
return newOpts;
}