-
Notifications
You must be signed in to change notification settings - Fork 143
Add country validation to subscription inclusion #7777
Conversation
louwie17
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@octaedro Things were testing well, and overall the changes look great!
I just left a couple small comments, and one question in relation to the getTaskLists invalidation call, otherwise close to ready 👍
| useEffect( () => { | ||
| if ( panelsData.isTaskListHidden !== undefined ) { | ||
| if ( ! panelsData.isTaskListHidden ) { | ||
| invalidateResolutionForStoreSelector( 'getTaskLists' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to cause the getTaskLists request to be triggered twice when loading the homescreen for the first time.
Was there a specific reason for adding this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the invalidateResolutionForStoreSelector here thinking about the following use case:
The user sets US as the store's country in step one of the OBW; then they select Subscriptions in step three (Product Types) and press Continue, after that they go to the first step and press Skip setup store details.
They won't be able to see the task item Add Subscriptions to my store in the setup task list.
Then, they go back to the OBW, select another country, and press Skip setup store details. The task item Add Subscriptions to my store should be visible in the setup task list.
If we don't invalidate the resolution the user will see the old list instead of the updated one until they refresh the page.
Do you think it would be better for us to add the resolution invalidation in the OBW instead of here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would be better for us to add the resolution invalidation in the OBW instead of here?
Yeah I think doing it in the OBW is a better idea, either when the user finishes it or skips it.
This might be the easiest, I was thinking otherwise to only do it when the country changes, but that's not correct given some tasks depend on the other selected options (like subscriptions as you mentioned).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. I moved the invalidateResolutionForStoreSelector in the commit 83266f1
| }; | ||
|
|
||
| export const getProductTypes = ( state: OnboardingState ): Product[] => { | ||
| return state.productTypes || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is in a selector that gets memoized, could you define the empty array as a constant outside of this function and return that?
const EMPTY_ARRAY = [];
export const getProductTypes = ( state: OnboardingState ): Product[] => {
return state.productTypes || EMPTY_ARRAY;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I added this change in the commit 02ee720
| export type Product = { | ||
| default: boolean; | ||
| label: string; | ||
| product: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
product seems to be a number.
Both default and product are also optional, so just add ? before :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! I added this in the commit 5a53635
|
Thank you @louwie17 for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @octaedro, it looks great and still tested well 😄
|
@octaedro @mattsherman these changes do look good, but it is a rather large change to be cherry-picking into our RC version. So just wanted to ask if it is necessary to cherry-pick this? and if so, if we could forgo any of the refactored changes? It might require a couple more thorough tests if we do go ahead. |
It is quite a large change. Much larger than I would have expected to add country validation!
Yes, it is necessary, as the subscription support needs to be in there in this release, and it needs to be limited to US only. Unfortunately, this requirement was not known initially when the support was added.
@octaedro @louwie17 What other areas than this particular scenario should we test? |
mattsherman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works as expected. Code looks good, just a minor comment or two that doesn't need to be addressed in this PR, given that it has already been tested and reviewed and our timeline.
This PR is quite large to cherry-pick, but given the requirements and timeline, we will do so.
| import './style.scss'; | ||
| import sanitizeHTML from '~/lib/sanitize-html'; | ||
| import { setAllPropsToValue } from '~/lib/collections'; | ||
| import { getCountryCode } from '../../../../../../dashboard/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels really fragile (using so many relative parent paths). Is there no other way to reference this that doesn't use parent paths?
It doesn't need to be fixed in this PR, since it is working now and has been tested/reviewed, but it would be good to cleanup in a follow up PR.
| * Internal dependencies | ||
| */ | ||
| import { createNoticesFromResponse } from '~/lib/notices'; | ||
| import { getCountryCode } from '../../../dashboard/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
Co-authored-by: Fernando Marichal <[email protected]>
…erce-admin#7777) * Add country validation * Add OnboardingProductTypes * Add OnboardingProductTypes * Add country validation to product task * Add `productTypes` data handling * Add country validation and new productTypes handling * Fix to get `productTypes` from a SSOT * Add `invalidateResolution` for `getTaskLists` * Fixed testing instructions * Fix `isTaskListHidden` issue * Fixed product type * Added constant `EMPTY_ARRAY` to `selectors.ts` * Fixed constant `EMPTY_ARRAY` * Moved `invalidateResolutionForStoreSelector` into OBW * Updated testing instructions * Updated testing instructions * Fixed testing instructions Co-authored-by: Fernando Marichal <[email protected]>

This is a follow-up to PR 7734 to add a country validation.
The Subscription inclusion will be visible only for
USstores and this PR adds the changes necessary to accomplish that.The requested changes here also required a small refactor to how we handle the product types.
No changelog is necessary.
Detailed test instructions:
WooCommerce Paymentsif you have it installed.France(or any country other than the US) as the storeCountry / Region.Product Types) and verifySubscriptionsis shown as a paid extension (with a price chip).Subscriptionsand continue with the OBW.Homescreen by pressingSkip setup store detailsin the step one of the store profiler. Check that the task itemAdd Subscriptions to my storeis visible in the setup task list.Add my productsin the setup task list.Start with a template. Verify that the optionSubscription productis not visible in the popup.USas the storeCountry / Region.Subscriptionsis shown as free (without a price chip). Also, verify that the textis visible at the bottom when
WooCommerce Paymentsis not installed.Subscriptionsand pressContinueand verify that theWooCommerce Paymentsplugin is installed and activated and it's not shown in theFree featureslistVerify that the
WooCommerce Paymentsplugin is being shown in theFree featureslist when the store country is other than theUS.Go back to the
Homescreen by pressingSkip setup store detailsin step one of the store profiler. Check that the task itemAdd Subscriptions to my storeis not visible in the setup task list. It should be visible if the store is from any country other than the US.Press
Add my productsin the setup task list.Select
Start with a template. Verify that the optionSubscription productis visible in the popup (verify that this is not being shown when the store is from a country other than the US)UPDATE