diff --git a/services/web/frontend/js/features/subscription/components/dashboard/states/active/active-ai-addon.tsx b/services/web/frontend/js/features/subscription/components/dashboard/states/active/active-ai-addon.tsx index ec2728b25b..c44a9fe656 100644 --- a/services/web/frontend/js/features/subscription/components/dashboard/states/active/active-ai-addon.tsx +++ b/services/web/frontend/js/features/subscription/components/dashboard/states/active/active-ai-addon.tsx @@ -10,10 +10,12 @@ import { ConfirmChangePlanModal } from './change-plan/modals/confirm-change-plan import { KeepCurrentPlanModal } from './change-plan/modals/keep-current-plan-modal' import { ChangeToGroupModal } from './change-plan/modals/change-to-group-modal' import { CancelAiAddOnModal } from './change-plan/modals/cancel-ai-add-on-modal' +import { PendingRecurlyPlan } from '../../../../../../../../types/subscription/plan' import { - AI_STANDALONE_PLAN_CODE, ADD_ON_NAME, + AI_ADD_ON_CODE, AI_STANDALONE_PLAN_NAME, + AI_STANDALONE_PLAN_CODE, AI_STANDALONE_ANNUAL_PLAN_CODE, } from '../../../../data/add-on-codes' import { CancelSubscriptionButton } from './cancel-subscription-button' @@ -110,6 +112,7 @@ export function ActiveAiAddonSubscription({ )}

@@ -155,9 +158,8 @@ function StandaloneAiPlanActions({ {t('upgrade')} - - {t('cancel_add_on')} + {t('remove_add_on')} ) @@ -166,11 +168,25 @@ function StandaloneAiPlanActions({ function PlanWithAddonsActions({ handlePlanChange, handleCancelClick, + subscription, }: { handlePlanChange(): void handleCancelClick(): void + subscription: RecurlySubscription }) { const { t } = useTranslation() + + const pendingPlan = subscription.pendingPlan as PendingRecurlyPlan + + const hasAiAddon = subscription.addOns?.some( + addOn => addOn.addOnCode === AI_ADD_ON_CODE + ) + + const pendingCancellation = Boolean( + hasAiAddon && + pendingPlan && + !pendingPlan.addOns?.some(addOn => addOn.add_on_code === AI_ADD_ON_CODE) + ) return ( <> @@ -178,9 +194,11 @@ function PlanWithAddonsActions({ <> - - {t('remove_add_on')} - {' '} + {!pendingCancellation && ( + + {t('remove_add_on')} + + )}