From d798dbec01f517a100964b63b30fe8df0c12093f Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Tue, 6 May 2025 11:23:50 -0400 Subject: [PATCH] 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 --- .../states/active/pending-plan-change.tsx | 16 ++++--------- .../components/dashboard/states/canceled.tsx | 18 +++++++++++++++ .../subscription/data/add-on-codes.ts | 23 +++++++++++++++++++ 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/services/web/frontend/js/features/subscription/components/dashboard/states/active/pending-plan-change.tsx b/services/web/frontend/js/features/subscription/components/dashboard/states/active/pending-plan-change.tsx index 46d5a1cc90..cf7452941d 100644 --- a/services/web/frontend/js/features/subscription/components/dashboard/states/active/pending-plan-change.tsx +++ b/services/web/frontend/js/features/subscription/components/dashboard/states/active/pending-plan-change.tsx @@ -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 && diff --git a/services/web/frontend/js/features/subscription/components/dashboard/states/canceled.tsx b/services/web/frontend/js/features/subscription/components/dashboard/states/canceled.tsx index 569aaeba04..12838970d2 100644 --- a/services/web/frontend/js/features/subscription/components/dashboard/states/canceled.tsx +++ b/services/web/frontend/js/features/subscription/components/dashboard/states/canceled.tsx @@ -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({ ]} />

+ {pendingAiAddonCancellation && ( +

+ }} + /> +

+ )}

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) + +} \ No newline at end of file