2021-01-06 22:08:57 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useSelect } from '@wordpress/data';
|
|
|
|
import { Spinner } from '@woocommerce/components';
|
|
|
|
import { ONBOARDING_STORE_NAME, SETTINGS_STORE_NAME } from '@woocommerce/data';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-03-08 14:23:39 +00:00
|
|
|
import { BusinessDetailsStepWithExtensionList } from './flows/bundle';
|
2021-01-06 22:08:57 +00:00
|
|
|
import { SelectiveFeaturesBusinessStep } from './flows/selective-bundle';
|
|
|
|
import './style.scss';
|
|
|
|
import { isSelectiveBundleInstallSegmentation } from './data/segmentation';
|
|
|
|
|
|
|
|
export const BusinessDetailsStep = ( props ) => {
|
|
|
|
const { profileItems, settings, isLoading } = useSelect( ( select ) => {
|
|
|
|
return {
|
|
|
|
isLoading:
|
|
|
|
! select( ONBOARDING_STORE_NAME ).hasFinishedResolution(
|
|
|
|
'getProfileItems'
|
|
|
|
) ||
|
|
|
|
! select(
|
|
|
|
SETTINGS_STORE_NAME
|
|
|
|
).hasFinishedResolution( 'getSettings', [ 'general' ] ),
|
|
|
|
profileItems: select( ONBOARDING_STORE_NAME ).getProfileItems(),
|
|
|
|
settings:
|
|
|
|
select( SETTINGS_STORE_NAME ).getSettings( 'general' ) || {},
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
|
|
|
const country = settings.general
|
|
|
|
? settings.general.woocommerce_default_country
|
|
|
|
: null;
|
|
|
|
|
|
|
|
const selectiveBundleInstallSegmentation = isSelectiveBundleInstallSegmentation(
|
2021-03-08 14:23:39 +00:00
|
|
|
country
|
2021-01-06 22:08:57 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if ( isLoading ) {
|
|
|
|
return (
|
|
|
|
<div className="woocommerce-admin__business-details__spinner">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( selectiveBundleInstallSegmentation ) {
|
|
|
|
const initialValues = {
|
|
|
|
other_platform: profileItems.other_platform || '',
|
|
|
|
other_platform_name: profileItems.other_platform_name || '',
|
|
|
|
product_count: profileItems.product_count || '',
|
|
|
|
selling_venues: profileItems.selling_venues || '',
|
|
|
|
revenue: profileItems.revenue || '',
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SelectiveFeaturesBusinessStep
|
|
|
|
{ ...props }
|
|
|
|
initialValues={ initialValues }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-08 14:23:39 +00:00
|
|
|
return <BusinessDetailsStepWithExtensionList { ...props } />;
|
2021-01-06 22:08:57 +00:00
|
|
|
};
|