From 592c9d8e15c802114e3ee59cebd709cda061faaf Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Fri, 21 Jun 2019 12:51:56 -0400 Subject: [PATCH] Save value of the tracking setting on both 'next' and 'skip profiler actions (https://github.com/woocommerce/woocommerce-admin/pull/2468) --- .../profile-wizard/steps/start/index.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/woocommerce-admin/client/dashboard/profile-wizard/steps/start/index.js b/plugins/woocommerce-admin/client/dashboard/profile-wizard/steps/start/index.js index 73eaf292956..d5a9d5c15e9 100644 --- a/plugins/woocommerce-admin/client/dashboard/profile-wizard/steps/start/index.js +++ b/plugins/woocommerce-admin/client/dashboard/profile-wizard/steps/start/index.js @@ -69,12 +69,19 @@ class Start extends Component { this.skipWizard = this.skipWizard.bind( this ); } + async updateTracking() { + const { updateSettings } = this.props; + const allowTracking = this.state.allowTracking ? 'yes' : 'no'; + await updateSettings( { advanced: { woocommerce_allow_tracking: allowTracking } } ); + } + async skipWizard() { - const { addNotice, isProfileItemsError, updateProfileItems } = this.props; + const { addNotice, isProfileItemsError, updateProfileItems, isSettingsError } = this.props; await updateProfileItems( { skipped: true } ); + await this.updateTracking(); - if ( isProfileItemsError ) { + if ( isProfileItemsError || isSettingsError ) { addNotice( { status: 'error', message: __( 'There was a problem updating your preferences.', 'woocommerce-admin' ), @@ -83,10 +90,9 @@ class Start extends Component { } async startWizard() { - const { addNotice, isSettingsError, updateSettings } = this.props; + const { addNotice, isSettingsError } = this.props; - const allowTracking = this.state.allowTracking ? 'yes' : 'no'; - await updateSettings( { advanced: { woocommerce_allow_tracking: allowTracking } } ); + await this.updateTracking(); if ( ! isSettingsError ) { this.props.goToNextStep();