Skip to content

Commit

Permalink
Woop installer: restore autotransferring handling (#58811)
Browse files Browse the repository at this point in the history
* woop: restore autotransferring handling

* woop: fetch status in transfer step

* woop: add delay before redirect after transferring
  • Loading branch information
retrofox authored Dec 3, 2021
1 parent 9a028f7 commit c1bf48f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 7 additions & 1 deletion client/signup/steps/woocommerce-install/confirm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,21 @@ export default function Confirm( props: WooCommerceInstallProps ): ReactElement
isDataReady,
warnings,
isAtomicSite,
isReadyForTransfer,
} = useWooCommerceOnPlansEligibility( siteId );

useEffect( () => {
if ( ! isAtomicSite ) {
// Automatically start the transfer process when it's ready.
if ( isReadyForTransfer ) {
return goToStep( 'transfer' );
}

return;
}

page.redirect( `/woocommerce-installation/${ wpcomDomain }` );
}, [ isAtomicSite, wpcomDomain ] );
}, [ goToStep, isAtomicSite, isReadyForTransfer, wpcomDomain ] );

function getWPComSubdomainWarningContent() {
if ( ! wpcomSubdomainWarning ) {
Expand Down
20 changes: 19 additions & 1 deletion client/signup/steps/woocommerce-install/transfer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useI18n } from '@wordpress/react-i18n';
import { ReactElement, useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import StepWrapper from 'calypso/signup/step-wrapper';
import { fetchAutomatedTransferStatus } from 'calypso/state/automated-transfer/actions';
import { transferStates } from 'calypso/state/automated-transfer/constants';
import {
isFetchingAutomatedTransferStatus,
Expand Down Expand Up @@ -41,6 +42,7 @@ export default function Transfer( props: WooCommerceInstallProps ): ReactElement
return;
}

dispatch( fetchAutomatedTransferStatus( siteId ) );
dispatch( initiateThemeTransfer( siteId, null, 'woocommerce' ) );
}, [ siteId, dispatch ] );

Expand Down Expand Up @@ -78,7 +80,6 @@ export default function Transfer( props: WooCommerceInstallProps ): ReactElement
break;
case transferStates.COMPLETE:
setProgress( 1 );
window.location.href = wcAdmin;
break;
}

Expand Down Expand Up @@ -123,6 +124,23 @@ export default function Transfer( props: WooCommerceInstallProps ): ReactElement
return () => clearTimeout( timeOutReference );
}, [ simulatedProgress, progress, __ ] );

useEffect( () => {
if ( simulatedProgress < 1 ) {
return;
}

const timer = setTimeout( () => {
window.location.href = wcAdmin;
}, 5000 );

return function () {
if ( ! timer ) {
return;
}
window.clearTimeout( timer );
};
}, [ simulatedProgress, wcAdmin ] );

return (
<StepWrapper
flowName="woocommerce-install"
Expand Down

0 comments on commit c1bf48f

Please sign in to comment.