overleaf-cep/services/web/frontend/js/features/subscription/data/add-on-codes.ts
Jimmy Domagala-Tang 443fb3f152 Merge pull request #24739 from overleaf/dk-thankyou-page
Update "thanks for subscribing page" with AI Assist links

GitOrigin-RevId: 41a23d6fd5edfc8f9ad0f97e513e1ea66aed5bdc
2025-05-14 08:06:44 +00:00

32 lines
No EOL
1.1 KiB
TypeScript

import { PaidSubscription } from "../../../../../types/subscription/dashboard/subscription"
import { PendingPaymentProviderPlan } from "../../../../../types/subscription/plan"
export const AI_ASSIST_STANDALONE_MONTHLY_PLAN_CODE = 'assistant'
export const AI_ADD_ON_CODE = 'assistant'
// we dont want translations on plan or add-on names
export const ADD_ON_NAME = "AI Assist"
export const AI_ASSIST_STANDALONE_ANNUAL_PLAN_CODE = 'assistant-annual'
export function isStandaloneAiPlanCode(planCode?: string) {
return planCode === AI_ASSIST_STANDALONE_MONTHLY_PLAN_CODE || planCode === AI_ASSIST_STANDALONE_ANNUAL_PLAN_CODE
}
export function hasPendingAiAddonCancellation(subscription: PaidSubscription){
const pendingPlan = subscription.pendingPlan as PendingPaymentProviderPlan
const hasAiAddon = subscription.addOns?.some(
addOn => addOn.addOnCode === AI_ADD_ON_CODE
)
// cancellation of entire plan counts as removing the add-on
if(hasAiAddon && !pendingPlan){
return true
}
return hasAiAddon &&
!pendingPlan.addOns?.some(addOn => addOn.code === AI_ADD_ON_CODE)
}