refactor entitlements

This commit is contained in:
Alex Holliday committed 2025-12-11 18:07:22 +00:00
1 parent 9bfe146e2b
commit b6a3d1e34d
5 files changed
+40 -21

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { useMemo } from "react";
import { useAppSelector } from "@/hooks/AppHooks";
import { config } from "@/config";
export type PlanEntitlementKey =
| "monitorsMax"
| "notificationChannelsMax"
| "statusPagesMax"
| "checksIntervalMsMin"
| "teamsMax";
export function useLimitReached(
entitlement: PlanEntitlementKey | null,
currentCount: number
): boolean {
const entitlements = useAppSelector((s: any) => s.auth?.user?.entitlements);
return useMemo(() => {
if (config.DEPLOYMENT_MODE === "self_hosted") return false;
if (!entitlement) return false;
const value = entitlements?.[entitlement];
if (typeof value !== "number") return false;
return currentCount >= value;
}, [entitlement, currentCount, entitlements]);
}
export default useLimitReached;