mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #25252 from overleaf/jdt-add-addon-to-cancellation-mssg-in-subs
Show Assist Add-on for pending and cancelled subscriptions GitOrigin-RevId: df733d7078c231a5de989bc070b37e3c250fdb37
This commit is contained in:
committed by
Copybot
parent
dd74ba1613
commit
d798dbec01
+5
-11
@@ -1,7 +1,9 @@
|
||||
import { Trans } from 'react-i18next'
|
||||
import { PaidSubscription } from '../../../../../../../../types/subscription/dashboard/subscription'
|
||||
import { PendingPaymentProviderPlan } from '../../../../../../../../types/subscription/plan'
|
||||
import { AI_ADD_ON_CODE, ADD_ON_NAME } from '../../../../data/add-on-codes'
|
||||
import {
|
||||
hasPendingAiAddonCancellation,
|
||||
ADD_ON_NAME,
|
||||
} from '../../../../data/add-on-codes'
|
||||
|
||||
export function PendingPlanChange({
|
||||
subscription,
|
||||
@@ -10,15 +12,7 @@ export function PendingPlanChange({
|
||||
}) {
|
||||
if (!subscription.pendingPlan) return null
|
||||
|
||||
const pendingPlan = subscription.pendingPlan as PendingPaymentProviderPlan
|
||||
|
||||
const hasAiAddon = subscription.addOns?.some(
|
||||
addOn => addOn.addOnCode === AI_ADD_ON_CODE
|
||||
)
|
||||
|
||||
const pendingAiAddonCancellation =
|
||||
hasAiAddon &&
|
||||
!pendingPlan.addOns?.some(addOn => addOn.code === AI_ADD_ON_CODE)
|
||||
const pendingAiAddonCancellation = hasPendingAiAddonCancellation(subscription)
|
||||
|
||||
const pendingAdditionalLicenses =
|
||||
(subscription.payment.pendingAdditionalLicenses &&
|
||||
|
||||
+18
@@ -1,5 +1,9 @@
|
||||
import { useTranslation, Trans } from 'react-i18next'
|
||||
import { PaidSubscription } from '../../../../../../../types/subscription/dashboard/subscription'
|
||||
import {
|
||||
hasPendingAiAddonCancellation,
|
||||
ADD_ON_NAME,
|
||||
} from '../../../data/add-on-codes'
|
||||
import ReactivateSubscription from '../reactivate-subscription'
|
||||
import OLButton from '@/features/ui/components/ol/ol-button'
|
||||
|
||||
@@ -9,6 +13,7 @@ export function CanceledSubscription({
|
||||
subscription: PaidSubscription
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const pendingAiAddonCancellation = hasPendingAiAddonCancellation(subscription)
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -26,6 +31,19 @@ export function CanceledSubscription({
|
||||
]}
|
||||
/>
|
||||
</p>
|
||||
{pendingAiAddonCancellation && (
|
||||
<p>
|
||||
<Trans
|
||||
i18nKey="pending_addon_cancellation"
|
||||
values={{
|
||||
addOnName: ADD_ON_NAME,
|
||||
}}
|
||||
shouldUnescape
|
||||
tOptions={{ interpolation: { escapeValue: true } }}
|
||||
components={{ strong: <strong /> }}
|
||||
/>
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
<Trans
|
||||
i18nKey="subscription_canceled_and_terminate_on_x"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
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
|
||||
@@ -7,3 +10,23 @@ 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)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user