Skip to content

Commit

Permalink
Fix the exit checkout flow by proper redirecting back to /plans page
Browse files Browse the repository at this point in the history
  • Loading branch information
paulopmt1 committed Feb 1, 2025
1 parent 8bfb8cf commit 9cd65c7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useI18n } from '@wordpress/react-i18n';
import { useEffect, FormEvent, useState } from 'react';
import wpcomRequest from 'wpcom-proxy-request';
import { LoadingEllipsis } from 'calypso/components/loading-ellipsis';
import { useQuery } from 'calypso/landing/stepper/hooks/use-query';
import { SITE_STORE, ONBOARD_STORE } from 'calypso/landing/stepper/stores';
import { useIsBigSkyEligible } from '../../../../hooks/use-is-site-big-sky-eligible';
import { useSiteData } from '../../../../hooks/use-site-data';
Expand All @@ -14,7 +15,8 @@ import type { OnboardSelect } from '@automattic/data-stores';

const SiteIntent = Onboard.SiteIntent;

const LaunchBigSky: Step = function () {
const LaunchBigSky: Step = function ( props ) {
const { submit } = props.navigation;
const { __ } = useI18n();
const [ isError, setError ] = useState( false );
const { siteSlug, siteId, site } = useSiteData();
Expand All @@ -28,6 +30,8 @@ const LaunchBigSky: Step = function () {
const hasStaticHomepage = site?.options?.show_on_front === 'page' && site?.options?.page_on_front;
const assemblerThemeActive = site?.options?.theme_slug === 'pub/assembler';

const skippedCheckout = useQuery().get( 'skippedCheckout' );

const deletePage = async ( siteId: string, pageId: number ): Promise< boolean > => {
try {
await wpcomRequest( {
Expand All @@ -44,6 +48,14 @@ const LaunchBigSky: Step = function () {
}
};

useEffect( () => {
if ( skippedCheckout === '1' ) {
submit?.( {
skippedCheckout: true,
} );
}
}, [ skippedCheckout, submit ] );

useEffect( () => {
if ( ! isLoading && ! isEligible ) {
window.location.assign( '/start' );
Expand Down
6 changes: 6 additions & 0 deletions client/landing/stepper/declarative-flow/site-setup-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ const siteSetupFlow: FlowV1 = {
) }`
);
}

case 'launch-big-sky': {
if ( providedDependencies.skippedCheckout ) {
return exitFlow( `/setup/onboarding/plans` );
}
}
}
}

Expand Down

0 comments on commit 9cd65c7

Please sign in to comment.