mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 23:59:01 +02:00
f29bd47911
Show Assist Add-on for pending and cancelled subscriptions GitOrigin-RevId: df733d7078c231a5de989bc070b37e3c250fdb37
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { PaidSubscription } from "../../../../../types/subscription/dashboard/subscription"
|
|
import { PendingPaymentProviderPlan } from "../../../../../types/subscription/plan"
|
|
|
|
export const AI_STANDALONE_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 = "Error Assist"
|
|
export const AI_STANDALONE_ANNUAL_PLAN_CODE = 'assistant-annual'
|
|
|
|
export function isStandaloneAiPlanCode(planCode: string) {
|
|
return planCode === AI_STANDALONE_PLAN_CODE || planCode === AI_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)
|
|
|
|
} |