2021-01-06 22:08:57 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useSelect } from '@wordpress/data';
|
2022-07-14 05:38:33 +00:00
|
|
|
import { useMemo } from '@wordpress/element';
|
2022-07-21 04:57:46 +00:00
|
|
|
import { Spinner } from '@wordpress/components';
|
2021-01-06 22:08:57 +00:00
|
|
|
import { ONBOARDING_STORE_NAME, SETTINGS_STORE_NAME } from '@woocommerce/data';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2022-07-14 05:38:33 +00:00
|
|
|
import {
|
|
|
|
BusinessFeaturesList,
|
|
|
|
PERSIST_FREE_FEATURES_DATA_STORAGE_KEY,
|
|
|
|
} from './flows/selective-bundle';
|
2021-01-06 22:08:57 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
export const BusinessDetailsStep = ( props ) => {
|
2021-06-03 08:33:54 +00:00
|
|
|
const { profileItems, isLoading } = useSelect( ( select ) => {
|
2021-01-06 22:08:57 +00:00
|
|
|
return {
|
|
|
|
isLoading:
|
|
|
|
! select( ONBOARDING_STORE_NAME ).hasFinishedResolution(
|
|
|
|
'getProfileItems'
|
|
|
|
) ||
|
2022-06-21 08:37:34 +00:00
|
|
|
! select( SETTINGS_STORE_NAME ).hasFinishedResolution(
|
|
|
|
'getSettings',
|
|
|
|
[ 'general' ]
|
|
|
|
),
|
2021-01-06 22:08:57 +00:00
|
|
|
profileItems: select( ONBOARDING_STORE_NAME ).getProfileItems(),
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
2022-07-14 05:38:33 +00:00
|
|
|
const freeFeaturesTabValues = useMemo( () => {
|
|
|
|
try {
|
|
|
|
const values = JSON.parse(
|
|
|
|
window.localStorage.getItem(
|
|
|
|
PERSIST_FREE_FEATURES_DATA_STORAGE_KEY
|
|
|
|
)
|
|
|
|
);
|
|
|
|
if ( values ) {
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
} catch ( _e ) {
|
|
|
|
// Skip errors
|
|
|
|
}
|
|
|
|
return { install_extensions: true };
|
|
|
|
}, [] );
|
|
|
|
|
2021-01-06 22:08:57 +00:00
|
|
|
if ( isLoading ) {
|
|
|
|
return (
|
|
|
|
<div className="woocommerce-admin__business-details__spinner">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-03 08:33:54 +00:00
|
|
|
const initialValues = {
|
2022-07-14 05:38:33 +00:00
|
|
|
businessDetailsTab: {
|
|
|
|
number_employees: profileItems.number_employees || '',
|
|
|
|
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 || '',
|
|
|
|
setup_client: profileItems.setup_client || false,
|
|
|
|
},
|
|
|
|
freeFeaturesTab: freeFeaturesTabValues,
|
2021-06-03 08:33:54 +00:00
|
|
|
};
|
2021-01-06 22:08:57 +00:00
|
|
|
|
2021-06-03 08:33:54 +00:00
|
|
|
return (
|
|
|
|
<BusinessFeaturesList { ...props } initialValues={ initialValues } />
|
|
|
|
);
|
2021-01-06 22:08:57 +00:00
|
|
|
};
|