woocommerce/plugins/woocommerce-admin/client/core-profiler/pages/BusinessLocation.tsx

99 lines
2.8 KiB
TypeScript
Raw Normal View History

/**
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
* External dependencies
*/
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { SelectControl } from '@woocommerce/components';
import { Icon, chevronDown } from '@wordpress/icons';
import { useState } from '@wordpress/element';
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
/**
* Internal dependencies
*/
import {
BusinessLocationEvent,
CoreProfilerStateMachineContext,
} from '../index';
import { CountryStateOption } from '../services/country';
import { Heading } from '../components/heading/heading';
import { Navigation } from '../components/navigation/navigation';
export const BusinessLocation = ( {
sendEvent,
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
navigationProgress,
context,
}: {
sendEvent: ( event: BusinessLocationEvent ) => void;
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
navigationProgress: number;
context: Pick< CoreProfilerStateMachineContext, 'countries' >;
} ) => {
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
const [ storeCountry, setStoreCountry ] = useState< CountryStateOption >( {
key: '',
label: '',
} );
const inputLabel = __( 'Select country/region', 'woocommerce' );
return (
<div
className="woocommerce-profiler-business-location"
data-testid="core-profiler-business-location"
>
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
<Navigation percentage={ navigationProgress } />
<div className="woocommerce-profiler-page__content woocommerce-profiler-business-location__content">
<Heading
className="woocommerce-profiler__stepper-heading"
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
title={ __(
'Where is your business located?',
'woocommerce'
) }
subTitle={ __(
"We'll use this information to help you set up payments, shipping, and taxes.",
'woocommerce'
) }
/>
<SelectControl
className="woocommerce-profiler-select-control__country"
instanceId={ 1 }
placeholder={ inputLabel }
label={ storeCountry.key === '' ? inputLabel : '' }
getSearchExpression={ ( query: string ) => {
return new RegExp(
'(^' + query + '| — (' + query + '))',
'i'
);
} }
autoComplete="new-password" // disable autocomplete and autofill
options={ context.countries }
excludeSelectedOptions={ false }
help={ <Icon icon={ chevronDown } /> }
onChange={ ( results: Array< CountryStateOption > ) => {
if ( results.length ) {
setStoreCountry( results[ 0 ] );
}
} }
selected={ storeCountry ? [ storeCountry ] : [] }
showAllOnFocus
isSearchable
/>
<div className="woocommerce-profiler-button-container woocommerce-profiler-go-to-mystore__button-container">
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
<Button
className="woocommerce-profiler-button"
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
variant="primary"
disabled={ ! storeCountry.key }
onClick={ () => {
sendEvent( {
type: 'BUSINESS_LOCATION_COMPLETED',
payload: {
storeLocation: storeCountry.key,
Add Business Location page to the core profiler (#38019) * Add core profiler - welcome to woo page * Update checkbox styles * Add tracks * Update default tracking value * Update copies * using invoked promise instead of useState - take advantage of xstate's built ins for side effects instead of useEffect/hooks - discovered that error result wasn't really handled in original useEffect - use text labels instead of inline functions so that we can decouple the implementation from the machine model - todo: can move the invoked function out elsewhere and also tests if needed (not necessary here because it's a simple call) * add: core profiler scaffolding using xstate * Add navigation and progress-bar components * fix css lint error * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/woologo.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/progress-bar/progress-bar.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/components/navigation/navigation.tsx Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove var from __ function * Use woocommerce prefix for classnames * Fix css lint error * Fix broken tests * Add business location page * Remove unwanted changes from rebase * Remove unwanted changes from rebase * Redirect to Woo Home on exit * Add tracks * Fix js lint error * Add loader page * Support meta value from nested states * Use navigateTo * Add tests for getCountryStateOptions * Use Country type from navigation package * Rename useStages to getLoaderStageMeta * Add changelog * Move progress from 20 to 80 * Fix xstate warning * Fix broken pnpm lock * Fix eslint errors * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Update plugins/woocommerce-admin/client/core-profiler/index.tsx Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com> * Save country to option * Fix jslint error * Update plugins/woocommerce-admin/client/core-profiler/services/country.ts Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce-admin/client/core-profiler/style.scss Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Fix eslint error * Use decodeEntities directly * Update comment for artificial 3 seconds wait * Disable Go to my store button when country is empty * Style for mobile devices * Style updates for the country dropdown * Fix js lint error * Update country dropdown border color * Style the loader * Fix css lint --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> Co-authored-by: rjchow <me@rjchow.com> Co-authored-by: RJ <27843274+rjchow@users.noreply.github.com>
2023-05-14 20:56:47 +00:00
},
} );
} }
>
{ __( 'Go to my store', 'woocommerce' ) }
</Button>
</div>
</div>
</div>
);
};