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