1- import { useState } from 'react' ;
1+ import { useEffect , useState } from 'react' ;
22
33import ErrorBoundary from 'sentry/components/errorBoundary' ;
44import { useLocation } from 'sentry/utils/useLocation' ;
55import { useNavigate } from 'sentry/utils/useNavigate' ;
66import useOrganization from 'sentry/utils/useOrganization' ;
77
8+ import useSubscription from 'getsentry/hooks/useSubscription' ;
89import { PlanTier } from 'getsentry/types' ;
910import { hasPartnerMigrationFeature } from 'getsentry/utils/billing' ;
1011import AMCheckout from 'getsentry/views/amCheckout' ;
@@ -14,12 +15,22 @@ function DecideCheckout() {
1415 const navigate = useNavigate ( ) ;
1516 const location = useLocation ( ) ;
1617 const organization = useOrganization ( ) ;
18+ const subscription = useSubscription ( ) ;
1719 const [ tier , setTier ] = useState < string | null > ( null ) ;
20+ const isNewCheckout = hasCheckoutV3 ( organization ) ;
21+
22+ useEffect ( ( ) => {
23+ // if we're showing new checkout, ensure we show the checkout for
24+ // the current plan tier (we will not toggle between tiers for legacy checkout)
25+ if ( isNewCheckout ) {
26+ setTier ( subscription ?. planTier ?? null ) ;
27+ }
28+ } , [ subscription ?. planTier , isNewCheckout ] ) ;
1829
1930 const checkoutProps = {
2031 organization,
2132 onToggleLegacy : setTier ,
22- isNewCheckout : hasCheckoutV3 ( organization ) ,
33+ isNewCheckout,
2334 location,
2435 navigate,
2536 } ;
0 commit comments