@@ -364,6 +364,16 @@ const updateOnboardingProfileOption = (
364364 } ) ;
365365} ;
366366
367+ const spawnUpdateOnboardingProfileOption = assign ( {
368+ spawnUpdateOnboardingProfileOptionRef : (
369+ context : CoreProfilerStateMachineContext
370+ ) =>
371+ spawn (
372+ ( ) => updateOnboardingProfileOption ( context ) ,
373+ 'update-onboarding-profile'
374+ ) ,
375+ } ) ;
376+
367377const updateBusinessLocation = ( countryAndState : string ) => {
368378 return dispatch ( OPTIONS_STORE_NAME ) . updateOptions ( {
369379 woocommerce_default_country : countryAndState ,
@@ -389,7 +399,7 @@ const assignUserProfile = assign( {
389399
390400const updateBusinessInfo = async (
391401 _context : CoreProfilerStateMachineContext ,
392- event : BusinessInfoEvent
402+ event : AnyEventObject
393403) => {
394404 const refreshedOnboardingProfile = ( await resolveSelect (
395405 OPTIONS_STORE_NAME
@@ -518,6 +528,7 @@ const coreProfilerMachineActions = {
518528 handleOnboardingProfileOption,
519529 assignOnboardingProfile,
520530 persistBusinessInfo,
531+ spawnUpdateOnboardingProfileOption,
521532 redirectToWooHome,
522533} ;
523534
@@ -530,6 +541,7 @@ const coreProfilerMachineServices = {
530541 getOnboardingProfileOption,
531542 getPlugins,
532543 browserPopstateHandler,
544+ updateBusinessInfo,
533545} ;
534546export const coreProfilerStateMachineDefinition = createMachine ( {
535547 id : 'coreProfiler' ,
@@ -772,16 +784,9 @@ export const coreProfilerStateMachineDefinition = createMachine( {
772784 ] ) ,
773785 } ,
774786 postUserProfile : {
775- invoke : {
776- src : ( context ) => {
777- return updateOnboardingProfileOption ( context ) ;
778- } ,
779- onDone : {
780- target : '#businessInfo' ,
781- } ,
782- onError : {
783- target : '#businessInfo' ,
784- } ,
787+ entry : [ 'spawnUpdateOnboardingProfileOption' ] ,
788+ always : {
789+ target : '#businessInfo' ,
785790 } ,
786791 } ,
787792 } ,
@@ -938,11 +943,19 @@ export const coreProfilerStateMachineDefinition = createMachine( {
938943 ] ,
939944 on : {
940945 BUSINESS_INFO_COMPLETED : {
946+ target : 'postBusinessInfo' ,
947+ actions : [ 'recordTracksBusinessInfoCompleted' ] ,
948+ } ,
949+ } ,
950+ } ,
951+ postBusinessInfo : {
952+ invoke : {
953+ src : 'updateBusinessInfo' ,
954+ onDone : {
955+ target : '#plugins' ,
956+ } ,
957+ onError : {
941958 target : '#plugins' ,
942- actions : [
943- 'persistBusinessInfo' ,
944- 'recordTracksBusinessInfoCompleted' ,
945- ] ,
946959 } ,
947960 } ,
948961 } ,
@@ -1337,8 +1350,8 @@ export const CoreProfilerController = ( {
13371350 ) ;
13381351
13391352 const navigationProgress = currentNodeMeta ?. progress ;
1340- const CurrentComponent =
1341- currentNodeMeta ?. component ?? ( ( ) => < ProfileSpinner /> ) ; // If no component is defined for the state then its a loading state
1353+
1354+ const CurrentComponent = currentNodeMeta ?. component ;
13421355
13431356 const currentNodeCssLabel =
13441357 state . value instanceof Object
@@ -1364,13 +1377,15 @@ export const CoreProfilerController = ( {
13641377 < div
13651378 className = { `woocommerce-profile-wizard__container woocommerce-profile-wizard__step-${ currentNodeCssLabel } ` }
13661379 >
1367- {
1380+ { CurrentComponent ? (
13681381 < CurrentComponent
13691382 navigationProgress = { navigationProgress }
13701383 sendEvent = { send }
13711384 context = { state . context }
13721385 />
1373- }
1386+ ) : (
1387+ < ProfileSpinner />
1388+ ) }
13741389 </ div >
13751390 </ >
13761391 ) ;
0 commit comments