Files
formbricks/apps/web/app/lib/utils.ts
Matti Nannt 9872d17abe feat: AI-based Open-Text Summary & new Experience page (#3038)
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com>
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
2024-10-20 12:06:46 +02:00

28 lines
1.1 KiB
TypeScript

import { getEnterpriseLicense } from "@formbricks/ee/lib/service";
import { IS_AI_CONFIGURED, IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants";
import { TInvite } from "@formbricks/types/invites";
import { TOrganization, TOrganizationBillingPlan } from "@formbricks/types/organizations";
export const isInviteExpired = (invite: TInvite) => {
const now = new Date();
const expiresAt = new Date(invite.expiresAt);
return now > expiresAt;
};
export const getIsOrganizationAIReady = async (billingPlan: TOrganizationBillingPlan) => {
const { active: isEnterpriseEdition } = await getEnterpriseLicense();
// TODO: We'll remove the IS_FORMBRICKS_CLOUD check once we have the AI feature available for self-hosted customers
return Boolean(
IS_FORMBRICKS_CLOUD &&
IS_AI_CONFIGURED &&
isEnterpriseEdition &&
(billingPlan === "startup" || billingPlan === "scale" || billingPlan === "enterprise")
);
};
export const getIsAIEnabled = async (organization: TOrganization) => {
const isOrganizationAIReady = await getIsOrganizationAIReady(organization.billing.plan);
return Boolean(isOrganizationAIReady && organization.isAIEnabled);
};