Files
cfw-autumn/shared/utils/cusEntUtils/classifyCusEnt/cusEntsHaveUsageAllowed.ts
2026-04-13 10:24:58 +01:00

22 lines
633 B
TypeScript

import type { FullCusEntWithFullCusProduct } from "../../../models/cusProductModels/cusEntModels/cusEntWithProduct.js";
import { nullish } from "../../utils.js";
export const cusEntsHaveUsageAllowed = ({
cusEnts,
internalFeatureId,
includeUsageLimit = true,
}: {
cusEnts: FullCusEntWithFullCusProduct[];
internalFeatureId: string;
includeUsageLimit?: boolean;
}) => {
return cusEnts.some(
(customerEntitlement) =>
customerEntitlement.internal_feature_id === internalFeatureId &&
customerEntitlement.usage_allowed &&
(includeUsageLimit
? nullish(customerEntitlement.entitlement.usage_limit)
: true),
);
};