From 8bea077b9334719fe814f523c1150736f9465de4 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Thu, 28 Nov 2024 08:19:34 -0500 Subject: [PATCH] Merge pull request #22163 from overleaf/em-subscription-page-ai-add-on Adapt the Your plan entry on the subscription page to groups and Commons GitOrigin-RevId: 7352a90d2489de48d2711f2b8a364cdd5bb54eeb --- .../states/active/active-ai-addon.tsx | 35 ++++++++++++++----- .../subscription/data/add-on-codes.ts | 1 - 2 files changed, 27 insertions(+), 9 deletions(-) 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 b257ca2754..f004770989 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 @@ -14,7 +14,6 @@ import { PendingRecurlyPlan } from '../../../../../../../../types/subscription/p import { ADD_ON_NAME, AI_ADD_ON_CODE, - AI_STANDALONE_PLAN_NAME, isStandaloneAiPlanCode, } from '../../../../data/add-on-codes' import { CancelSubscriptionButton } from './cancel-subscription-button' @@ -27,12 +26,36 @@ export function ActiveAiAddonSubscription({ subscription: RecurlySubscription }) { const { t } = useTranslation() - const { recurlyLoadError, showCancellation, setModalIdShown } = - useSubscriptionDashboardContext() + const { + recurlyLoadError, + showCancellation, + setModalIdShown, + memberGroupSubscriptions, + institutionMemberships, + } = useSubscriptionDashboardContext() if (showCancellation) return const onStandalonePlan = isStandaloneAiPlanCode(subscription.planCode) + let planName + if (onStandalonePlan) { + planName = 'Overleaf Free' + if (institutionMemberships && institutionMemberships.length > 0) { + planName = 'Overleaf Professional' + } + if (memberGroupSubscriptions.length > 0) { + if ( + memberGroupSubscriptions.some(s => s.planLevelName === 'Professional') + ) { + planName = 'Overleaf Professional' + } else { + planName = 'Overleaf Standard' + } + } + } else { + planName = subscription.plan.name + } + const handlePlanChange = () => setModalIdShown('change-plan') const handleCancelClick = () => setModalIdShown('cancel-ai-add-on') @@ -42,11 +65,7 @@ export function ActiveAiAddonSubscription({

}} diff --git a/services/web/frontend/js/features/subscription/data/add-on-codes.ts b/services/web/frontend/js/features/subscription/data/add-on-codes.ts index c13efaa720..52d47f98b9 100644 --- a/services/web/frontend/js/features/subscription/data/add-on-codes.ts +++ b/services/web/frontend/js/features/subscription/data/add-on-codes.ts @@ -2,7 +2,6 @@ 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_PLAN_NAME = "Overleaf Free" export const AI_STANDALONE_ANNUAL_PLAN_CODE = 'assistant-annual' export function isStandaloneAiPlanCode(planCode: string) {