saleor-dashboard/src/utils/limits.ts
Michał Droń d5c9a3dae8
Add trailing commas (#2062)
* Require trailing commas

* Add trailing commas

* Add trailing commas in testUtils dir

* Add trailing commas
2022-06-21 11:36:55 +02:00

23 lines
540 B
TypeScript

import { LimitInfoFragment, RefreshLimitsQuery } from "@saleor/graphql";
export function hasLimits(
limits: RefreshLimitsQuery["shop"]["limits"],
key: keyof LimitInfoFragment,
): boolean {
if (limits === undefined) {
return false;
}
return limits.allowedUsage[key] !== null;
}
export function isLimitReached(
limits: RefreshLimitsQuery["shop"]["limits"],
key: keyof LimitInfoFragment,
): boolean {
if (!hasLimits(limits, key)) {
return false;
}
return limits.currentUsage[key] >= limits.allowedUsage[key];
}