|
|
@@ -4,6 +4,7 @@ import { useSubscriptionDashboardContext } from '../../../../context/subscriptio
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
import { PaidSubscription } from '../../../../../../../../types/subscription/dashboard/subscription'
|
|
|
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
|
+import { useLocation } from '@/shared/hooks/use-location'
|
|
|
|
|
|
export function CancelSubscriptionButton() {
|
|
|
const { t } = useTranslation()
|
|
|
@@ -13,6 +14,7 @@ export function CancelSubscriptionButton() {
|
|
|
setModalIdShown,
|
|
|
setShowCancellation,
|
|
|
} = useSubscriptionDashboardContext()
|
|
|
+ const location = useLocation()
|
|
|
|
|
|
const subscription = personalSubscription as PaidSubscription
|
|
|
const isInTrial =
|
|
|
@@ -29,14 +31,22 @@ export function CancelSubscriptionButton() {
|
|
|
useFeatureFlag('pause-subscription') &&
|
|
|
!hasPendingOrActivePause &&
|
|
|
planIsEligibleForPause
|
|
|
+ const shouldContactSupport =
|
|
|
+ subscription.payment.state === 'paused' &&
|
|
|
+ subscription.payment.remainingPauseCycles === 0
|
|
|
|
|
|
function handleCancelSubscriptionClick() {
|
|
|
eventTracking.sendMB('subscription-page-cancel-button-click', {
|
|
|
plan_code: subscription?.planCode,
|
|
|
is_trial: isInTrial,
|
|
|
})
|
|
|
- if (enablePause) setModalIdShown('pause-subscription')
|
|
|
- else setShowCancellation(true)
|
|
|
+ if (shouldContactSupport) {
|
|
|
+ location.assign('/contact')
|
|
|
+ } else if (enablePause) {
|
|
|
+ setModalIdShown('pause-subscription')
|
|
|
+ } else {
|
|
|
+ setShowCancellation(true)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (recurlyLoadError) return null
|