2019-06-12 03:56:10 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2021-03-08 14:23:39 +00:00
|
|
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
2019-06-12 03:56:10 +00:00
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
|
|
|
import { compose } from '@wordpress/compose';
|
2020-07-01 12:20:24 +00:00
|
|
|
import {
|
|
|
|
Button,
|
2020-12-21 19:34:22 +00:00
|
|
|
Card,
|
|
|
|
CardBody,
|
|
|
|
CardFooter,
|
2020-07-01 12:20:24 +00:00
|
|
|
FormToggle,
|
|
|
|
} from '@wordpress/components';
|
2020-03-25 03:20:17 +00:00
|
|
|
import { withDispatch, withSelect } from '@wordpress/data';
|
2019-11-05 00:05:20 +00:00
|
|
|
import { keys, get, pickBy } from 'lodash';
|
2021-03-08 14:23:39 +00:00
|
|
|
import { H, SelectControl, Form, TextControl } from '@woocommerce/components';
|
2020-04-02 21:54:38 +00:00
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
2020-06-12 06:38:33 +00:00
|
|
|
import {
|
|
|
|
ONBOARDING_STORE_NAME,
|
|
|
|
PLUGINS_STORE_NAME,
|
|
|
|
pluginNames,
|
|
|
|
SETTINGS_STORE_NAME,
|
2020-12-29 21:21:24 +00:00
|
|
|
OPTIONS_STORE_NAME,
|
2020-06-12 06:38:33 +00:00
|
|
|
} from '@woocommerce/data';
|
2020-08-20 04:59:52 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2021-01-07 23:57:09 +00:00
|
|
|
import { Text } from '@woocommerce/experimental';
|
2019-06-12 03:56:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-03-10 15:11:37 +00:00
|
|
|
import { CurrencyContext } from '~/lib/currency-context';
|
|
|
|
import { createNoticesFromResponse } from '~/lib/notices';
|
2021-01-06 22:08:57 +00:00
|
|
|
import { extensionBenefits } from '../../data/extension-benefits';
|
|
|
|
import { sellingVenueOptions } from '../../data/selling-venue-options';
|
|
|
|
import { platformOptions } from '../../data/platform-options';
|
|
|
|
import { getRevenueOptions } from '../../data/revenue-options';
|
|
|
|
import { getProductCountOptions } from '../../data/product-options';
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2019-09-23 21:47:08 +00:00
|
|
|
const wcAdminAssetUrl = getSetting( 'wcAdminAssetUrl', '' );
|
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
class BusinessDetails extends Component {
|
2019-11-05 00:05:20 +00:00
|
|
|
constructor( props ) {
|
2019-06-12 03:56:10 +00:00
|
|
|
super();
|
2019-11-05 00:05:20 +00:00
|
|
|
const profileItems = get( props, 'profileItems', {} );
|
2020-02-14 02:23:21 +00:00
|
|
|
const businessExtensions = get(
|
|
|
|
profileItems,
|
|
|
|
'business_extensions',
|
|
|
|
false
|
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2020-07-01 12:20:24 +00:00
|
|
|
this.state = {
|
|
|
|
isPopoverVisible: false,
|
|
|
|
};
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
this.initialValues = {
|
2019-11-05 00:05:20 +00:00
|
|
|
other_platform: profileItems.other_platform || '',
|
2020-03-06 19:20:54 +00:00
|
|
|
other_platform_name: profileItems.other_platform_name || '',
|
2019-11-05 00:05:20 +00:00
|
|
|
product_count: profileItems.product_count || '',
|
|
|
|
selling_venues: profileItems.selling_venues || '',
|
|
|
|
revenue: profileItems.revenue || '',
|
|
|
|
'facebook-for-woocommerce': businessExtensions
|
|
|
|
? businessExtensions.includes( 'facebook-for-woocommerce' )
|
|
|
|
: true,
|
|
|
|
'mailchimp-for-woocommerce': businessExtensions
|
|
|
|
? businessExtensions.includes( 'mailchimp-for-woocommerce' )
|
|
|
|
: true,
|
2020-11-06 00:55:44 +00:00
|
|
|
'creative-mail-by-constant-contact': businessExtensions
|
|
|
|
? businessExtensions.includes(
|
|
|
|
'creative-mail-by-constant-contact'
|
|
|
|
)
|
2021-03-09 18:00:34 +00:00
|
|
|
: false,
|
2021-05-10 09:56:47 +00:00
|
|
|
'google-listings-and-ads': businessExtensions
|
|
|
|
? businessExtensions.includes( 'google-listings-and-ads' )
|
2020-03-16 06:12:30 +00:00
|
|
|
: true,
|
2021-03-09 18:00:34 +00:00
|
|
|
mailpoet: businessExtensions
|
|
|
|
? businessExtensions.includes( 'mailpoet' )
|
|
|
|
: true,
|
2020-07-01 12:20:24 +00:00
|
|
|
install_extensions: true,
|
2019-06-12 03:56:10 +00:00
|
|
|
};
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
this.extensions = [
|
2021-03-09 18:00:34 +00:00
|
|
|
'mailpoet',
|
2020-02-14 02:23:21 +00:00
|
|
|
'facebook-for-woocommerce',
|
|
|
|
'mailchimp-for-woocommerce',
|
2021-05-10 09:56:47 +00:00
|
|
|
'google-listings-and-ads',
|
2020-11-06 00:55:44 +00:00
|
|
|
'creative-mail-by-constant-contact',
|
2020-02-14 02:23:21 +00:00
|
|
|
];
|
2019-08-08 05:25:55 +00:00
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
this.onContinue = this.onContinue.bind( this );
|
2019-08-08 05:25:55 +00:00
|
|
|
this.validate = this.validate.bind( this );
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 21:21:24 +00:00
|
|
|
onCreativeMailInstallAndActivated() {
|
|
|
|
const { updateOptions } = this.props;
|
|
|
|
updateOptions( {
|
|
|
|
ce4wp_referred_by: {
|
|
|
|
plugin: 'woocommerce',
|
|
|
|
version: getSetting( 'wcVersion' ),
|
|
|
|
time: Math.floor( new Date().getTime() / 1000 ),
|
|
|
|
source: 'onboarding',
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
onPostInstallAndActivePlugins( response ) {
|
|
|
|
const activated = response.data.activated;
|
|
|
|
if ( activated.includes( 'creative-mail-by-constant-contact' ) ) {
|
|
|
|
this.onCreativeMailInstallAndActivated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
async onContinue( values ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
const {
|
|
|
|
createNotice,
|
|
|
|
goToNextStep,
|
2020-06-12 06:38:33 +00:00
|
|
|
installAndActivatePlugins,
|
2020-02-14 02:23:21 +00:00
|
|
|
updateProfileItems,
|
|
|
|
} = this.props;
|
|
|
|
const {
|
2020-07-01 12:20:24 +00:00
|
|
|
install_extensions: installExtensions,
|
2020-02-14 02:23:21 +00:00
|
|
|
other_platform: otherPlatform,
|
2020-03-06 19:20:54 +00:00
|
|
|
other_platform_name: otherPlatformName,
|
2020-02-14 02:23:21 +00:00
|
|
|
product_count: productCount,
|
|
|
|
revenue,
|
|
|
|
selling_venues: sellingVenues,
|
|
|
|
} = values;
|
2019-08-08 05:25:55 +00:00
|
|
|
const businessExtensions = this.getBusinessExtensions( values );
|
2020-06-17 23:33:40 +00:00
|
|
|
const { getCurrencyConfig } = this.context;
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2019-07-01 18:13:29 +00:00
|
|
|
recordEvent( 'storeprofiler_store_business_details_continue', {
|
2020-02-14 02:23:21 +00:00
|
|
|
product_number: productCount,
|
2020-03-09 11:39:38 +00:00
|
|
|
already_selling: sellingVenues,
|
2020-06-17 23:33:40 +00:00
|
|
|
currency: getCurrencyConfig().code,
|
2019-08-08 15:38:47 +00:00
|
|
|
revenue,
|
2020-02-14 02:23:21 +00:00
|
|
|
used_platform: otherPlatform,
|
2020-03-06 19:20:54 +00:00
|
|
|
used_platform_name: otherPlatformName,
|
2020-07-01 12:20:24 +00:00
|
|
|
install_woocommerce_services: businessExtensions.includes(
|
2020-11-13 20:31:18 +00:00
|
|
|
'woocommerce-services'
|
2020-07-01 12:20:24 +00:00
|
|
|
),
|
|
|
|
install_jetpack: businessExtensions.includes( 'jetpack' ),
|
|
|
|
install_facebook: businessExtensions.includes(
|
|
|
|
'facebook-for-woocommerce'
|
|
|
|
),
|
2021-03-09 18:00:34 +00:00
|
|
|
install_mailpoet: businessExtensions.includes( 'mailpoet' ),
|
2020-07-01 12:20:24 +00:00
|
|
|
install_mailchimp: businessExtensions.includes(
|
|
|
|
'mailchimp-for-woocommerce'
|
|
|
|
),
|
2020-11-06 00:55:44 +00:00
|
|
|
install_creative_mail: businessExtensions.includes(
|
|
|
|
'creative-mail-by-constant-contact'
|
|
|
|
),
|
2020-07-01 12:20:24 +00:00
|
|
|
install_google_ads: businessExtensions.includes(
|
2021-05-10 09:56:47 +00:00
|
|
|
'google-listing-and-ads'
|
2020-07-01 12:20:24 +00:00
|
|
|
),
|
|
|
|
install_extensions: installExtensions,
|
2019-07-01 18:13:29 +00:00
|
|
|
} );
|
|
|
|
|
2019-08-08 15:38:47 +00:00
|
|
|
const _updates = {
|
2020-02-14 02:23:21 +00:00
|
|
|
other_platform: otherPlatform,
|
2020-03-06 19:20:54 +00:00
|
|
|
other_platform_name:
|
|
|
|
otherPlatform === 'other' ? otherPlatformName : '',
|
2020-02-14 02:23:21 +00:00
|
|
|
product_count: productCount,
|
2019-08-08 15:38:47 +00:00
|
|
|
revenue,
|
2020-02-14 02:23:21 +00:00
|
|
|
selling_venues: sellingVenues,
|
2019-07-15 11:09:31 +00:00
|
|
|
business_extensions: businessExtensions,
|
2019-08-08 15:38:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Remove possible empty values like `revenue` and `other_platform`.
|
|
|
|
const updates = {};
|
2020-02-14 02:23:21 +00:00
|
|
|
Object.keys( _updates ).forEach( ( key ) => {
|
2019-08-08 15:38:47 +00:00
|
|
|
if ( _updates[ key ] !== '' ) {
|
|
|
|
updates[ key ] = _updates[ key ];
|
|
|
|
}
|
2019-07-04 15:56:28 +00:00
|
|
|
} );
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2020-06-12 06:38:33 +00:00
|
|
|
const promises = [
|
|
|
|
updateProfileItems( updates ).catch( () => {
|
|
|
|
throw new Error();
|
|
|
|
} ),
|
|
|
|
];
|
2019-10-23 15:17:38 +00:00
|
|
|
|
2020-06-12 06:38:33 +00:00
|
|
|
if ( businessExtensions.length ) {
|
|
|
|
promises.push(
|
|
|
|
installAndActivatePlugins( businessExtensions )
|
|
|
|
.then( ( response ) => {
|
|
|
|
createNoticesFromResponse( response );
|
2020-12-29 21:21:24 +00:00
|
|
|
this.onPostInstallAndActivePlugins( response );
|
2020-06-12 06:38:33 +00:00
|
|
|
} )
|
|
|
|
.catch( ( error ) => {
|
|
|
|
createNoticesFromResponse( error );
|
|
|
|
throw new Error();
|
|
|
|
} )
|
2019-07-23 03:26:46 +00:00
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
2020-06-12 06:38:33 +00:00
|
|
|
|
2020-07-15 14:52:21 +00:00
|
|
|
Promise.all( promises )
|
|
|
|
.then( () => {
|
|
|
|
goToNextStep();
|
|
|
|
} )
|
|
|
|
.catch( () => {
|
|
|
|
createNotice(
|
|
|
|
'error',
|
|
|
|
__(
|
2021-02-10 23:57:51 +00:00
|
|
|
'There was a problem updating your business details',
|
2020-07-15 14:52:21 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} );
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
validate( values ) {
|
|
|
|
const errors = {};
|
|
|
|
|
2020-07-01 12:20:24 +00:00
|
|
|
if ( ! values.product_count.length ) {
|
|
|
|
errors.product_count = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! values.selling_venues.length ) {
|
|
|
|
errors.selling_venues = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
! values.other_platform.length &&
|
|
|
|
[ 'other', 'brick-mortar-other' ].includes( values.selling_venues )
|
|
|
|
) {
|
|
|
|
errors.other_platform = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
! values.other_platform_name &&
|
|
|
|
values.other_platform === 'other' &&
|
|
|
|
[ 'other', 'brick-mortar-other' ].includes( values.selling_venues )
|
|
|
|
) {
|
|
|
|
errors.other_platform_name = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
! values.revenue.length &&
|
|
|
|
[
|
|
|
|
'other',
|
|
|
|
'brick-mortar',
|
|
|
|
'brick-mortar-other',
|
|
|
|
'other-woocommerce',
|
|
|
|
].includes( values.selling_venues )
|
|
|
|
) {
|
|
|
|
errors.revenue = __(
|
|
|
|
'This field is required',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
|
|
|
}
|
2019-07-15 11:09:31 +00:00
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
return errors;
|
2019-07-15 11:09:31 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
getBusinessExtensions( values ) {
|
2020-07-01 12:20:24 +00:00
|
|
|
if ( values.selling_venues === '' ) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
return keys( pickBy( values ) ).filter( ( name ) =>
|
|
|
|
this.extensions.includes( name )
|
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
renderBusinessExtensionHelpText( values ) {
|
2020-06-12 06:38:33 +00:00
|
|
|
const { isInstallingActivating } = this.props;
|
2019-08-08 05:25:55 +00:00
|
|
|
const extensions = this.getBusinessExtensions( values );
|
2019-07-04 15:56:28 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
if ( extensions.length === 0 ) {
|
2019-07-04 15:56:28 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-10-23 15:17:38 +00:00
|
|
|
const extensionsList = extensions
|
2020-02-14 02:23:21 +00:00
|
|
|
.map( ( extension ) => {
|
2019-10-23 15:17:38 +00:00
|
|
|
return pluginNames[ extension ];
|
|
|
|
} )
|
|
|
|
.join( ', ' );
|
|
|
|
|
2020-06-12 06:38:33 +00:00
|
|
|
if ( isInstallingActivating ) {
|
2020-01-06 15:16:38 +00:00
|
|
|
return (
|
2020-09-01 08:47:49 +00:00
|
|
|
<Text variant="caption" as="p">
|
2020-01-06 15:16:38 +00:00
|
|
|
{ sprintf(
|
|
|
|
_n(
|
|
|
|
'Installing the following plugin: %s',
|
|
|
|
'Installing the following plugins: %s',
|
|
|
|
extensions.length,
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
extensionsList
|
|
|
|
) }
|
2020-09-01 08:47:49 +00:00
|
|
|
</Text>
|
2020-01-06 15:16:38 +00:00
|
|
|
);
|
2019-10-23 15:17:38 +00:00
|
|
|
}
|
2019-07-04 15:56:28 +00:00
|
|
|
return (
|
2020-09-03 23:35:06 +00:00
|
|
|
<div className="woocommerce-profile-wizard__footnote">
|
|
|
|
<Text variant="caption" as="p">
|
|
|
|
{ sprintf(
|
|
|
|
_n(
|
2021-03-08 14:23:39 +00:00
|
|
|
'The following plugin will be installed for free: %s.',
|
|
|
|
'The following plugins will be installed for free: %s.',
|
2020-09-03 23:35:06 +00:00
|
|
|
extensions.length,
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2021-03-08 14:23:39 +00:00
|
|
|
extensionsList
|
2020-09-03 23:35:06 +00:00
|
|
|
) }
|
|
|
|
</Text>
|
|
|
|
</div>
|
2019-07-04 15:56:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
renderBusinessExtensions( values, getInputProps ) {
|
2020-07-01 12:20:24 +00:00
|
|
|
// Show extensions when the currently selling elsewhere checkbox has been answered.
|
|
|
|
if ( values.selling_venues === '' ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-07-04 15:56:28 +00:00
|
|
|
return (
|
2020-12-21 19:34:22 +00:00
|
|
|
<div>
|
2020-03-16 06:12:30 +00:00
|
|
|
{ extensionBenefits.map( ( benefit ) => (
|
|
|
|
<div
|
|
|
|
className="woocommerce-profile-wizard__benefit"
|
|
|
|
key={ benefit.title }
|
|
|
|
>
|
|
|
|
<div className="woocommerce-profile-wizard__business-extension">
|
|
|
|
<img
|
|
|
|
src={ wcAdminAssetUrl + benefit.icon }
|
|
|
|
alt=""
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-profile-wizard__benefit-content">
|
|
|
|
<H className="woocommerce-profile-wizard__benefit-title">
|
|
|
|
{ benefit.title }
|
|
|
|
</H>
|
|
|
|
<p>{ benefit.description }</p>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-profile-wizard__benefit-toggle">
|
|
|
|
<FormToggle
|
|
|
|
checked={ values[ benefit.slug ] }
|
|
|
|
{ ...getInputProps( benefit.slug ) }
|
|
|
|
/>
|
2019-07-04 15:56:28 +00:00
|
|
|
</div>
|
2020-03-16 06:12:30 +00:00
|
|
|
</div>
|
|
|
|
) ) }
|
2020-12-21 19:34:22 +00:00
|
|
|
</div>
|
2019-07-04 15:56:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-12 03:56:10 +00:00
|
|
|
render() {
|
2020-06-12 06:38:33 +00:00
|
|
|
const {
|
|
|
|
goToNextStep,
|
|
|
|
isInstallingActivating,
|
|
|
|
hasInstallActivateError,
|
2020-12-01 22:56:17 +00:00
|
|
|
isUpdatingProfileItems,
|
2020-06-12 06:38:33 +00:00
|
|
|
} = this.props;
|
2021-04-28 02:54:49 +00:00
|
|
|
const { formatAmount, getCurrencyConfig } = this.context;
|
2019-08-08 15:38:47 +00:00
|
|
|
|
2021-01-06 22:08:57 +00:00
|
|
|
const productCountOptions = getProductCountOptions(
|
|
|
|
getCurrencyConfig()
|
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
|
2021-01-06 22:08:57 +00:00
|
|
|
const revenueOptions = getRevenueOptions(
|
|
|
|
getCurrencyConfig(),
|
2021-04-28 02:54:49 +00:00
|
|
|
this.props.settings.woocommerce_default_country,
|
|
|
|
formatAmount
|
2021-01-06 22:08:57 +00:00
|
|
|
);
|
2019-06-12 03:56:10 +00:00
|
|
|
|
|
|
|
return (
|
2019-08-08 05:25:55 +00:00
|
|
|
<Form
|
|
|
|
initialValues={ this.initialValues }
|
2021-05-18 04:24:24 +00:00
|
|
|
onSubmit={ this.onContinue }
|
2019-08-08 05:25:55 +00:00
|
|
|
validate={ this.validate }
|
|
|
|
>
|
2019-10-04 13:46:27 +00:00
|
|
|
{ ( { getInputProps, handleSubmit, values, isValidForm } ) => {
|
2021-03-08 14:23:39 +00:00
|
|
|
const businessExtensions = this.renderBusinessExtensions(
|
|
|
|
values,
|
|
|
|
getInputProps
|
|
|
|
);
|
2020-12-21 19:34:22 +00:00
|
|
|
|
2019-08-08 05:25:55 +00:00
|
|
|
return (
|
|
|
|
<Fragment>
|
2020-09-01 08:47:49 +00:00
|
|
|
<div className="woocommerce-profile-wizard__step-header">
|
|
|
|
<Text variant="title.small" as="h2">
|
|
|
|
{ __(
|
|
|
|
'Tell us about your business',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
|
|
|
</Text>
|
|
|
|
<Text variant="body">
|
|
|
|
{ __(
|
|
|
|
"We'd love to know if you are just getting started or you already have a business in place.",
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
|
|
|
</Text>
|
|
|
|
</div>
|
2019-08-08 05:25:55 +00:00
|
|
|
<Card>
|
2020-12-21 19:34:22 +00:00
|
|
|
<CardBody>
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2020-02-14 02:23:21 +00:00
|
|
|
label={ __(
|
2020-03-06 19:20:54 +00:00
|
|
|
'How many products do you plan to display?',
|
2020-02-14 02:23:21 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
options={ productCountOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'product_count' ) }
|
|
|
|
/>
|
|
|
|
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2020-02-14 02:23:21 +00:00
|
|
|
label={ __(
|
|
|
|
'Currently selling elsewhere?',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-08-08 05:25:55 +00:00
|
|
|
options={ sellingVenueOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'selling_venues' ) }
|
|
|
|
/>
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
{ [
|
|
|
|
'other',
|
|
|
|
'brick-mortar',
|
|
|
|
'brick-mortar-other',
|
|
|
|
'other-woocommerce',
|
|
|
|
].includes( values.selling_venues ) && (
|
2019-10-07 22:42:32 +00:00
|
|
|
<SelectControl
|
2020-02-14 02:23:21 +00:00
|
|
|
label={ __(
|
|
|
|
"What's your current annual revenue?",
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-08-08 15:38:47 +00:00
|
|
|
options={ revenueOptions }
|
|
|
|
required
|
|
|
|
{ ...getInputProps( 'revenue' ) }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
{ [
|
|
|
|
'other',
|
|
|
|
'brick-mortar-other',
|
|
|
|
].includes( values.selling_venues ) && (
|
2020-03-06 19:20:54 +00:00
|
|
|
<Fragment>
|
2020-04-13 14:43:57 +00:00
|
|
|
<div className="business-competitors">
|
|
|
|
<SelectControl
|
2020-03-06 19:20:54 +00:00
|
|
|
label={ __(
|
2020-04-13 14:43:57 +00:00
|
|
|
'Which platform is the store using?',
|
2020-03-06 19:20:54 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2021-01-06 22:08:57 +00:00
|
|
|
options={ platformOptions }
|
2020-03-06 19:20:54 +00:00
|
|
|
required
|
|
|
|
{ ...getInputProps(
|
2020-04-13 14:43:57 +00:00
|
|
|
'other_platform'
|
2020-03-06 19:20:54 +00:00
|
|
|
) }
|
|
|
|
/>
|
2020-04-13 14:43:57 +00:00
|
|
|
{ values.other_platform ===
|
|
|
|
'other' && (
|
|
|
|
<TextControl
|
|
|
|
label={ __(
|
|
|
|
'What is the platform name?',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
|
|
|
required
|
|
|
|
{ ...getInputProps(
|
|
|
|
'other_platform_name'
|
|
|
|
) }
|
|
|
|
/>
|
|
|
|
) }
|
|
|
|
</div>
|
2020-03-06 19:20:54 +00:00
|
|
|
</Fragment>
|
2019-08-08 05:25:55 +00:00
|
|
|
) }
|
2020-12-21 19:34:22 +00:00
|
|
|
</CardBody>
|
|
|
|
{ businessExtensions && (
|
|
|
|
<CardFooter>
|
|
|
|
{ businessExtensions }
|
|
|
|
</CardFooter>
|
|
|
|
) }
|
|
|
|
<CardFooter justify="center">
|
|
|
|
<Button
|
|
|
|
isPrimary
|
|
|
|
onClick={ handleSubmit }
|
|
|
|
disabled={
|
|
|
|
! isValidForm ||
|
|
|
|
isUpdatingProfileItems ||
|
|
|
|
isInstallingActivating
|
|
|
|
}
|
|
|
|
isBusy={ isInstallingActivating }
|
|
|
|
>
|
|
|
|
{ ! hasInstallActivateError
|
|
|
|
? __(
|
|
|
|
'Continue',
|
|
|
|
'woocommerce-admin'
|
|
|
|
)
|
|
|
|
: __(
|
|
|
|
'Retry',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
|
|
|
</Button>
|
|
|
|
{ hasInstallActivateError && (
|
2019-10-23 15:17:38 +00:00
|
|
|
<Button
|
2020-12-21 19:34:22 +00:00
|
|
|
onClick={ () => goToNextStep() }
|
2019-10-23 15:17:38 +00:00
|
|
|
>
|
2020-12-21 19:34:22 +00:00
|
|
|
{ __(
|
|
|
|
'Continue without installing',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-10-23 15:17:38 +00:00
|
|
|
</Button>
|
2020-12-21 19:34:22 +00:00
|
|
|
) }
|
|
|
|
</CardFooter>
|
2019-08-08 05:25:55 +00:00
|
|
|
</Card>
|
|
|
|
|
2020-07-01 12:20:24 +00:00
|
|
|
{ this.renderBusinessExtensionHelpText( values ) }
|
2019-08-08 05:25:55 +00:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
} }
|
|
|
|
</Form>
|
2019-06-12 03:56:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 21:54:38 +00:00
|
|
|
BusinessDetails.contextType = CurrencyContext;
|
|
|
|
|
2021-03-08 14:23:39 +00:00
|
|
|
export const BusinessDetailsStepWithExtensionList = compose(
|
2020-03-27 15:57:25 +00:00
|
|
|
withSelect( ( select ) => {
|
2020-12-01 22:56:17 +00:00
|
|
|
const {
|
|
|
|
getSettings,
|
|
|
|
getSettingsError,
|
|
|
|
isUpdateSettingsRequesting,
|
|
|
|
} = select( SETTINGS_STORE_NAME );
|
|
|
|
const {
|
|
|
|
getProfileItems,
|
|
|
|
getOnboardingError,
|
|
|
|
isOnboardingRequesting,
|
|
|
|
} = select( ONBOARDING_STORE_NAME );
|
2020-06-12 06:38:33 +00:00
|
|
|
const { getPluginsError, isPluginsRequesting } = select(
|
|
|
|
PLUGINS_STORE_NAME
|
|
|
|
);
|
2020-03-25 03:20:17 +00:00
|
|
|
const { general: settings = {} } = getSettings( 'general' );
|
|
|
|
|
|
|
|
return {
|
2020-06-12 06:38:33 +00:00
|
|
|
hasInstallActivateError:
|
|
|
|
getPluginsError( 'installPlugins' ) ||
|
|
|
|
getPluginsError( 'activatePlugins' ),
|
|
|
|
isError: Boolean( getOnboardingError( 'updateProfileItems' ) ),
|
|
|
|
profileItems: getProfileItems(),
|
|
|
|
isSettingsError: Boolean( getSettingsError( 'general' ) ),
|
2019-12-10 19:01:21 +00:00
|
|
|
settings,
|
2020-12-01 22:56:17 +00:00
|
|
|
isUpdatingProfileItems:
|
|
|
|
isOnboardingRequesting( 'updateProfileItems' ) ||
|
|
|
|
isUpdateSettingsRequesting( 'general' ),
|
2020-06-12 06:38:33 +00:00
|
|
|
isInstallingActivating:
|
|
|
|
isPluginsRequesting( 'installPlugins' ) ||
|
|
|
|
isPluginsRequesting( 'activatePlugins' ) ||
|
|
|
|
isPluginsRequesting( 'getJetpackConnectUrl' ),
|
2019-11-05 00:05:20 +00:00
|
|
|
};
|
2019-06-12 03:56:10 +00:00
|
|
|
} ),
|
2020-02-14 02:23:21 +00:00
|
|
|
withDispatch( ( dispatch ) => {
|
2020-05-28 08:51:40 +00:00
|
|
|
const { updateProfileItems } = dispatch( ONBOARDING_STORE_NAME );
|
2020-06-12 06:38:33 +00:00
|
|
|
const { installAndActivatePlugins } = dispatch( PLUGINS_STORE_NAME );
|
2019-07-23 03:26:46 +00:00
|
|
|
const { createNotice } = dispatch( 'core/notices' );
|
2020-12-29 21:21:24 +00:00
|
|
|
const { updateOptions } = dispatch( OPTIONS_STORE_NAME );
|
2019-06-12 03:56:10 +00:00
|
|
|
|
|
|
|
return {
|
2019-07-23 03:26:46 +00:00
|
|
|
createNotice,
|
2020-06-12 06:38:33 +00:00
|
|
|
installAndActivatePlugins,
|
2019-06-12 03:56:10 +00:00
|
|
|
updateProfileItems,
|
2020-12-29 21:21:24 +00:00
|
|
|
updateOptions,
|
2019-06-12 03:56:10 +00:00
|
|
|
};
|
|
|
|
} )
|
|
|
|
)( BusinessDetails );
|