2023-06-21 09:28:00 +00:00
|
|
|
// @ts-strict-ignore
|
2023-01-16 09:45:12 +00:00
|
|
|
import { IFilter } from "@dashboard/components/Filter";
|
2021-05-14 08:15:15 +00:00
|
|
|
import clone from "lodash/clone";
|
2020-01-13 14:26:10 +00:00
|
|
|
|
2021-03-09 08:44:09 +00:00
|
|
|
export function getExistingKeys(o: {}): string[] {
|
2020-01-13 14:26:10 +00:00
|
|
|
return Object.keys(o).filter(key => o[key] !== undefined && o[key] !== null);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setFilterOptsStatus<T extends string>(
|
|
|
|
opts: IFilter<T>,
|
2023-01-16 09:45:12 +00:00
|
|
|
status: boolean,
|
2020-01-13 14:26:10 +00:00
|
|
|
): IFilter<T> {
|
|
|
|
const newOpts = clone(opts);
|
|
|
|
for (const optName in opts) {
|
|
|
|
if (Object.prototype.hasOwnProperty.call(newOpts, optName)) {
|
|
|
|
newOpts[optName].active = status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return newOpts;
|
|
|
|
}
|