Skip to content

Commit

Permalink
Onboarding: Fix going back from Checkout to Stepper (#97074)
Browse files Browse the repository at this point in the history
  • Loading branch information
alshakero authored and mehmoodak committed Dec 6, 2024
1 parent deb2654 commit 5d20a1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import { useStepPersistedState } from '@automattic/onboarding';
import { withShoppingCart } from '@automattic/shopping-cart';
import { localize } from 'i18n-calypso';
import { isEmpty } from 'lodash';
import { useRef, useCallback, useEffect } from 'react';
import { useRef, useCallback } from 'react';
import { connect } from 'react-redux';
import { recordUseYourDomainButtonClick } from 'calypso/components/domains/register-domain-step/analytics';
import { planItem } from 'calypso/lib/cart-values/cart-items';
import CalypsoShoppingCartProvider from 'calypso/my-sites/checkout/calypso-shopping-cart-provider';
import withCartKey from 'calypso/my-sites/checkout/with-cart-key';
import { RenderDomainsStep, submitDomainStepSelection } from 'calypso/signup/steps/domains';
import {
wasSignupCheckoutPageUnloaded,
retrieveSignupDestination,
getSignupCompleteFlowName,
} from 'calypso/signup/storageUtils';
import { recordTracksEvent } from 'calypso/state/analytics/actions';
import { NON_PRIMARY_DOMAINS_TO_FREE_USERS } from 'calypso/state/current-user/constants';
import {
Expand Down Expand Up @@ -100,18 +95,6 @@ export default function DomainsStep( props: StepProps ) {
},
[ stepState, setStepState ]
);
useEffect( () => {
// This will automatically submit the domains step when navigating back from checkout
// It will redirect the user to plans step. The idea is to achieve the same behavior as /start.
const signupDestinationCookieExists = retrieveSignupDestination();
const isReEnteringFlow = getSignupCompleteFlowName() === props.flow;
const isManageSiteFlow = Boolean(
wasSignupCheckoutPageUnloaded() && signupDestinationCookieExists && isReEnteringFlow
);
if ( isManageSiteFlow ) {
props.navigation.submit?.( stepState );
}
}, [ stepState, props.navigation, props.flow ] );

return (
<CalypsoShoppingCartProvider>
Expand Down
2 changes: 1 addition & 1 deletion client/landing/stepper/declarative-flow/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const onboarding: Flow = {
}
}
setSignupCompleteFlowName( flowName );
return navigate( 'create-site', undefined, true );
return navigate( 'create-site', undefined, false );
}
case 'create-site':
return navigate( 'processing', undefined, true );
Expand Down

0 comments on commit 5d20a1d

Please sign in to comment.