[web] fix bug where pending downgrades are removed when subscriptions change (#30420)

* preserve pending changes when generating change requests
* re-apply pending term_end changes after immediate updates
* block changes when Stripe subscription has multiple phases
* handle MultiplePendingChangesError & rm PendingChangeError

GitOrigin-RevId: 0af11044766ff48e683d684ad6d62b732d17290c
This commit is contained in:
Kristina
2026-02-03 09:05:55 +00:00
committed by Copybot
parent ee4b5f515c
commit 4c5cdecffa
19 changed files with 1179 additions and 129 deletions
@@ -368,7 +368,7 @@ function FlexibleGroupLicensingActions({
}) {
const { t } = useTranslation()
if (subscription.pendingPlan || subscription.payment.hasPastDueInvoice) {
if (subscription.payment.hasPastDueInvoice) {
return null
}
@@ -38,22 +38,24 @@ function KeepCurrentPlanButton() {
function ChangePlanButton({ plan }: { plan: Plan }) {
const { t } = useTranslation()
const { personalSubscription } = useSubscriptionDashboardContext()
const currentPlanCode = personalSubscription?.planCode?.split('_')[0]
const pendingPlanCode =
personalSubscription?.pendingPlan?.planCode?.split('_')[0]
const isCurrentPlanForUser =
personalSubscription?.planCode &&
plan.planCode === personalSubscription.planCode.split('_')[0]
currentPlanCode && plan.planCode === currentPlanCode
if (isCurrentPlanForUser) {
if (pendingPlanCode && pendingPlanCode !== currentPlanCode) {
return <KeepCurrentPlanButton />
}
if (isCurrentPlanForUser && personalSubscription.pendingPlan) {
return <KeepCurrentPlanButton />
} else if (isCurrentPlanForUser && !personalSubscription.pendingPlan) {
return (
<b className="d-inline-flex align-items-center">
<MaterialIcon type="check" />
&nbsp;{t('your_plan')}
</b>
)
} else if (
personalSubscription?.pendingPlan?.planCode?.split('_')[0] === plan.planCode
) {
} else if (pendingPlanCode === plan.planCode) {
return (
<b className="d-inline-flex align-items-center">
<MaterialIcon type="check" />