Files
overleaf-cep/services/web/frontend/js/shared/utils/ai-features.ts
T
Malik Glossop 15bc30b596 Merge pull request #36140 from overleaf/mg-ai-usage-limit-show
Add 'ai-usage-limit-show' event for ai limits

GitOrigin-RevId: 887ecc8b3fea52bcd45cf771ab0d22b8f4539308
2026-09-17 11:52:30 +00:00

30 lines
986 B
TypeScript

import getMeta from '@/utils/meta'
import { AiFeatureLocations, PaywallType } from '../components/types/ai'
export const paywallTypeByLocation: Record<AiFeatureLocations, PaywallType> = {
workbench: 'workbench',
errorAssist: 'assistant',
citationsReviewer: 'citations-reviewer',
}
// Returns the plan type for a limit with no upgrade path, or null when an
// upgrade is offered. Membership is checked before quota so commons/group users
// with unlimited AI aren't reported as individual; group before commons matches
// the rendered paywall's precedence for users who are in both.
export function getAiPlanTypeWithoutUpgrade(
hasUnlimitedQuota: boolean
): 'commons' | 'group' | 'individual' | null {
const { hasInstitutionLicence, isMemberOfGroupSubscription } =
getMeta('ol-user')
if (isMemberOfGroupSubscription) {
return 'group'
}
if (hasInstitutionLicence) {
return 'commons'
}
if (hasUnlimitedQuota) {
return 'individual'
}
return null
}