mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-13 21:53:43 +01:00
Add 'ai-usage-limit-show' event for ai limits GitOrigin-RevId: 887ecc8b3fea52bcd45cf771ab0d22b8f4539308
30 lines
986 B
TypeScript
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
|
|
}
|