saleor-dashboard/testUtils/filters.ts
Patryk Andrzejewski 1d2eeb7592
Strict mode plugin (#3778)
* Stric mode plugin

* Update command
2023-06-21 11:28:00 +02:00

21 lines
556 B
TypeScript

// @ts-strict-ignore
import { IFilter } from "@dashboard/components/Filter";
import clone from "lodash/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;
}