mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-25 10:20:03 -06:00
Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com> Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
28 lines
1.1 KiB
TypeScript
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);
|
|
};
|