Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Conversation

@joshuatf
Copy link
Contributor

Fixes #4631
Fixes #4667

After the wp data transition, we now have access to async updates. Since the await is now working, this caused some odd behavior on component update.

The logic in this component became tricky to follow and similar to other various updates around onboarding, this PR makes use of returned promises from wp data actions and attempts to minimize the state.

@pmcpinto @jameskoster It looks like with the current behavior, plugins only get installed on the tax step if TOS is already accepted, which currently will only occur if they opt in on the benefits screen from the profiler. This seems redundant- should we remove the plugins step from here or is it possible to allow plugin installation and opt in to TOS from this step?

Detailed test instructions:

  1. On a fresh install, walk through the profiler, using a TaxJar supported country (e.g., US) and opting in at the benefits screen in the profiler.
  2. Navigate to the tax task.
  3. Make sure the "success" screen is shown and that click "Yes please" is successful and returns to the task list without redirecting to the tax configuration screen.
  4. Deactivate WCS and/or Jetpack.
  5. Go to the task tax again.
  6. Check that you can manually configure taxes.
  7. Go to General WC Settings and remove required pieces of your address.
  8. Navigate back to the task tax.
  9. Make sure you're able to fill in your address and complete the steps.
  10. Also make sure that "skip" actions continue to work as expected.
  11. Make sure busy states work as expected.

@joshuatf joshuatf requested a review from a team June 24, 2020 11:57
@joshuatf joshuatf self-assigned this Jun 24, 2020
@jameskoster
Copy link
Member

If we can simply add a "by installing Jetpack and WooCommerce Services you agree to the TOS" line somewhere, and preserve plugin installation in this step, that would be worth it imo.

@jeffstieler
Copy link
Contributor

Closing and reopening to kick off a Travis CI build. Sorry for the noise!

@jeffstieler jeffstieler reopened this Jun 24, 2020
@jeffstieler
Copy link
Contributor

This needs to be rebased from main to fix the failing test.

Copy link
Contributor

@psealock psealock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome @joshuatf. What was happening to cause the redirect?

I came across an error.

Screen Shot 2020-06-25 at 4 25 05 PM\

Here is the error in minified code:

Screen Shot 2020-06-25 at 4 26 34 PM

Looks like its coming from

export function getCountryCode( countryState ) {
if ( ! countryState ) {
return null;
}
return countryState.split( ':' )[ 0 ];
}

To reproduce:

  1. Remove Address field from WC settings
  2. Tax Task
  3. Enter address and continue
  4. See the error. If you refresh and try again, it succeeds.

Otherwise the original bug is no longer there.

@psealock psealock added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed [Status] Needs Review labels Jun 25, 2020
@joshuatf
Copy link
Contributor Author

Thanks for the review, @psealock! I wasn't able to reproduce the address bug. Any other tricks that might help? What country did you have selected?

What was happening to cause the redirect?

Your guess (discussed in Slack) as to why this was happening was correct. The previous method of checking was to monitor changes to options and redirect when a change occurred.

componentDidUpdate() {
	...

	const {	
		woocommerce_calc_taxes: prevCalcTaxes,	
	} = prevProps.generalSettings;	
	if ( prevCalcTaxes === 'no' && calcTaxes === 'yes' ) {	
		window.location = getAdminLink(	
			'admin.php?page=wc-settings&tab=tax&section=standard'	
		);	
	}
}

Now that we have wp data actions returning promises, the await began to work when updating options and the component would update tax settings and redirect to the core tax screen before unmounting.

The logic in this task was generally a mess from previous development without promises, so I took this as an opportunity to refactor the whole thing.

We have quite a few other places in onboarding that are still in need of this, which I'll make note of in #2959. Besides async patterns that could use some patching from the days of wc-api, we also have some leftover error handling that won't work as expected.

@joshuatf
Copy link
Contributor Author

Also noting I added the change that @jameskoster requested in 024cf76. This shows the plugin step if plugins are needed or if opt-in to TOS is needed to enable automatic taxes.

Testing steps should be mostly identical, but disable Jetpack or WCS to also note that the plugins step will appear.

Screen Shot 2020-06-25 at 3 29 58 PM

@joshuatf joshuatf added [Status] Needs Review and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Jun 25, 2020
@psealock
Copy link
Contributor

I wasn't able to reproduce the address bug.

I tried again and wasn't able to do so consistently. I'm not sure what changed, but I tried it maybe 10 times and reproduced once. I'm ok with shipping this and seeing if we get reports of it happening in the wild.

the component would update tax settings and redirect to the core tax screen before unmounting.

Thats what I figured, but was thrown off by &section=standard because I didn't see that query param in my testing when redirected. 🤷 Thanks for the explanation and fix.

disable Jetpack or WCS to also note that the plugins step will appear.

This part is working well for me. I did notice one thing. When click "Install and enable" or "Continue" when having to enter my address, the Success screen showed and automatically moved on. Maybe thats because I already chose that option?

tax

@psealock psealock added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed [Status] Needs Review labels Jun 25, 2020
@joshuatf
Copy link
Contributor Author

This part is working well for me. I did notice one thing. When click "Install and enable" or "Continue" when having to enter my address, the Success screen showed and automatically moved on. Maybe thats because I already chose that option?

Great catch! I think this is happening because we call completeStep() and there's a generic catch to send us back to the task list if there are no more steps. Since the success screen isn't really part of the steps, it assumes the store address is the last step and redirects back to the task list.

I removed that snippet in ab1f19a as every step has a way of manually exiting this flow. Testing this seems to work well, but could use your 👀 to double check.

@joshuatf joshuatf added [Status] Needs Review and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Jun 26, 2020
@jameskoster
Copy link
Member

img

Nice! Would it be possible to use the caption Text style for this? And set the color to $dark-gray-300?

@joshuatf
Copy link
Contributor Author

Thanks for taking the time to look at this @jameskoster! Updated styling for captions in 3567fbf

Copy link
Contributor

@psealock psealock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thanks for addressing :shipit:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

focus: onboarding type: bug The issue is a confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task List: Setup tax step Success screen bad redirect Task List - Tax task: redirect to settings after enable automated taxes

5 participants