Handle core profiler get countries error (#48317)

* Handle core profiler get countries error

* Update style

* Add changefile(s) from automation for the following project(s): woocommerce

* Update button and code style

* Address feedback

* Fix lint

* Record skip step track and rename event

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chi-Hsuan Huang 2024-06-13 12:42:30 +08:00 committed by GitHub
parent ab1789afd2
commit 4112c97d13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 139 additions and 29 deletions

View File

@ -72,7 +72,7 @@ const recordTracksIsEmailChanged = ( {
event,
}: {
context: CoreProfilerStateMachineContext;
event: BusinessInfoEvent;
event: Extract< BusinessInfoEvent, { type: 'BUSINESS_INFO_COMPLETED' } >;
} ) => {
let emailSource, isEmailChanged;
if ( context.onboardingProfile.store_email ) {

View File

@ -42,7 +42,8 @@ export type UserProfileEvent =
payload: { userProfile: { skipped: true } };
};
export type BusinessInfoEvent = {
export type BusinessInfoEvent =
| {
type: 'BUSINESS_INFO_COMPLETED';
payload: {
storeName?: string;
@ -52,6 +53,12 @@ export type BusinessInfoEvent = {
isOptInMarketing: boolean;
storeEmailAddress: string;
};
}
| {
type: 'RETRY_PRE_BUSINESS_INFO';
}
| {
type: 'SKIP_BUSINESS_INFO_STEP';
};
export type BusinessLocationEvent = {

View File

@ -427,11 +427,18 @@ const assignUserProfile = assign( {
event.payload.userProfile,
} );
type BusinessInfoPayload = Extract<
BusinessInfoEvent,
{ type: 'BUSINESS_INFO_COMPLETED' }
>[ 'payload' ];
const updateBusinessInfo = fromPromise(
async ( {
input,
}: {
input: { payload: BusinessInfoEvent[ 'payload' ] };
input: {
payload: BusinessInfoPayload;
};
} ) => {
const refreshedOnboardingProfile = ( await resolveSelect(
OPTIONS_STORE_NAME
@ -590,6 +597,10 @@ export const getJetpackIsConnected = fromPromise( async () => {
return resolveSelect( PLUGINS_STORE_NAME ).isJetpackConnected();
} );
const reloadPage = () => {
window.location.reload();
};
export const preFetchActions = {
preFetchIsJetpackConnected,
preFetchJetpackAuthUrl,
@ -615,6 +626,7 @@ const coreProfilerMachineActions = {
redirectToWooHome,
redirectToJetpackAuthPage,
updateLoaderProgressWithPluginInstall,
reloadPage,
};
const coreProfilerMachineActors = {
@ -1096,6 +1108,18 @@ export const coreProfilerStateMachineDefinition = createMachine( {
'recordTracksIsEmailChanged',
],
},
RETRY_PRE_BUSINESS_INFO: {
actions: [ 'reloadPage' ],
},
SKIP_BUSINESS_INFO_STEP: {
target: '#plugins',
actions: [
{
type: 'recordTracksStepSkipped',
params: { step: 'business_info' },
},
],
},
},
},
postBusinessInfo: {

View File

@ -330,6 +330,52 @@ export const BusinessInfo = ( {
showAllOnFocus
isSearchable
/>
{ countries.length === 0 && (
<Notice
className="woocommerce-profiler-select-control__country-error"
isDismissible={ false }
status="error"
>
{ createInterpolateElement(
__(
'Oops! We encountered a problem while fetching the list of countries to choose from. <retryButton/> or <skipButton/>',
'woocommerce'
),
{
retryButton: (
<Button
onClick={ () => {
sendEvent( {
type: 'RETRY_PRE_BUSINESS_INFO',
} );
} }
variant="tertiary"
>
{ __(
'Please try again',
'woocommerce'
) }
</Button>
),
skipButton: (
<Button
onClick={ () => {
sendEvent( {
type: 'SKIP_BUSINESS_INFO_STEP',
} );
} }
variant="tertiary"
>
{ __(
'skip this step',
'woocommerce'
) }
</Button>
),
}
) }
</Notice>
) }
{ /* woocommerce-profiler-select-control__country-spacer exists purely because the select-control above has an unremovable and unstyleable div and that's preventing margin collapse */ }
<div className="woocommerce-profiler-select-control__country-spacer" />
{ geolocationOverruled && ! dismissedGeolocationNotice && (

View File

@ -150,8 +150,8 @@
@include breakpoint("<782px") {
margin-bottom: 40px;
background: url(./assets/images/welcome-mobile.svg) no-repeat
center center;
background: url(./assets/images/welcome-mobile.svg) no-repeat center
center;
width: 222px;
height: 144px;
}
@ -229,10 +229,8 @@
#woocommerce-select-control__listbox-0 {
top: 40px !important;
}
}
.woocommerce-profiler-business-location {
display: flex;
flex-direction: column;
@ -285,7 +283,11 @@
}
}
.woocommerce-experimental-select-control .components-popover .components-popover__content ul li:hover {
.woocommerce-experimental-select-control
.components-popover
.components-popover__content
ul
li:hover {
background-color: #f6f7f7 !important; // Gray-0
color: $gray-900;
}
@ -513,6 +515,33 @@
margin: 0;
}
.woocommerce-profiler-select-control__country-error {
background: #fce2e4;
padding: $gap-small;
font-size: 13px;
font-style: normal;
font-weight: 400;
line-height: 24px;
color: $gray-900;
margin: 12px 0;
.components-notice__content {
margin: 0;
}
.components-button {
padding: 0;
height: initial;
min-width: 24px;
min-height: 24px;
svg {
width: 16px;
fill: $gray-900;
}
}
}
.woocommerce-profiler-select-control__country-spacer {
margin: auto auto 12px auto;
}

View File

@ -0,0 +1,4 @@
Significance: patch
Type: enhancement
Handle core profiler get countries error