mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-26 18:51:50 +02:00
Merge pull request #23161 from overleaf/rh-pause-no-plan-change
Prevent downgrade to personal plan during subscription pause GitOrigin-RevId: e3ba2e8e4d9b909fa2ee9c3c7e15db2ed257e43b
This commit is contained in:
@@ -164,7 +164,9 @@ export function CancelSubscription() {
|
||||
const showDowngrade = showDowngradeOption(
|
||||
personalSubscription.plan.planCode,
|
||||
personalSubscription.plan.groupPlan,
|
||||
personalSubscription.recurly.trial_ends_at
|
||||
personalSubscription.recurly.trial_ends_at,
|
||||
personalSubscription.recurly.pausedAt,
|
||||
personalSubscription.recurly.remainingPauseCycles
|
||||
)
|
||||
const planToDowngradeTo = plans.find(
|
||||
plan => plan.planCode === planCodeToDowngradeTo
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { Nullable } from '../../../../../types/utils'
|
||||
import isInFreeTrial from './is-in-free-trial'
|
||||
import isMonthlyCollaboratorPlan from './is-monthly-collaborator-plan'
|
||||
|
||||
export default function showDowngradeOption(
|
||||
planCode: string,
|
||||
isGroupPlan?: boolean,
|
||||
trialEndsAt?: string | null
|
||||
trialEndsAt?: string | null,
|
||||
pausedAt?: Nullable<string>,
|
||||
remainingPauseCycles?: Nullable<number>
|
||||
) {
|
||||
return (
|
||||
!pausedAt &&
|
||||
!remainingPauseCycles &&
|
||||
isMonthlyCollaboratorPlan(planCode, isGroupPlan) &&
|
||||
!isInFreeTrial(trialEndsAt)
|
||||
)
|
||||
|
||||
@@ -44,4 +44,25 @@ describe('showDowngradeOption', function () {
|
||||
showDowngradeOption('collaborator', false, '2000-02-16T17:59:07.000Z')
|
||||
).to.be.true
|
||||
})
|
||||
it('returns false when on a monthly collaborator plan with a pending pause', function () {
|
||||
expect(
|
||||
showDowngradeOption(
|
||||
'collaborator',
|
||||
false,
|
||||
null,
|
||||
'2030-01-01T12:00:00.000Z'
|
||||
)
|
||||
).to.be.false
|
||||
})
|
||||
it('returns false when on a monthly collaborator plan with an active pause', function () {
|
||||
expect(
|
||||
showDowngradeOption(
|
||||
'collaborator',
|
||||
false,
|
||||
null,
|
||||
'2030-01-01T12:00:00.000Z',
|
||||
5
|
||||
)
|
||||
).to.be.false
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user