/** @format */ /** * External dependencies */ import { __, sprintf } from '@wordpress/i18n'; import { Button } from 'newspack-components'; import { Component, Fragment } from '@wordpress/element'; import { compose } from '@wordpress/compose'; import interpolateComponents from 'interpolate-components'; import { withDispatch } from '@wordpress/data'; import { filter, get } from 'lodash'; /** * WooCommerce depdencies */ import { Card, H, Link } from '@woocommerce/components'; import { updateQueryString } from '@woocommerce/navigation'; /** * Internal depdencies */ import CardIcon from './images/card'; import SecurityIcon from './images/security'; import SalesTaxIcon from './images/local_atm'; import SpeedIcon from './images/flash_on'; import MobileAppIcon from './images/phone_android'; import PrintIcon from './images/print'; import withSelect from 'wc-api/with-select'; import UsageModal from '../usage-modal'; import { recordEvent } from 'lib/tracks'; class Start extends Component { constructor( props ) { super( props ); this.state = { showUsageModal: false, continueAction: '', }; this.startWizard = this.startWizard.bind( this ); this.skipWizard = this.skipWizard.bind( this ); } componentDidMount() { const { updateProfileItems, profileItems, tosAccepted } = this.props; if ( this.props.activePlugins.includes( 'jetpack' ) && this.props.activePlugins.includes( 'woocommerce-services' ) && tosAccepted ) { // Don't track event again if they revisit the start page. if ( 'already-installed' !== profileItems.plugins ) { recordEvent( 'wcadmin_storeprofiler_already_installed_plugins', {} ); } updateProfileItems( { plugins: 'already-installed' } ); return updateQueryString( { step: 'store-details' } ); } } async skipWizard() { const { createNotice, isProfileItemsError, updateProfileItems, activePlugins } = this.props; const plugins = activePlugins.includes( 'jetpack' ) ? 'skipped-wcs' : 'skipped'; await updateProfileItems( { plugins } ); if ( isProfileItemsError ) { createNotice( 'error', __( 'There was a problem updating your preferences.', 'woocommerce-admin' ) ); } else { recordEvent( 'storeprofiler_welcome_clicked', { get_started: true, plugins } ); return updateQueryString( { step: 'store-details' } ); } } async startWizard() { const { createNotice, isProfileItemsError, updateProfileItems, updateOptions, goToNextStep, activePlugins, } = this.props; await updateOptions( { woocommerce_setup_jetpack_opted_in: true, } ); const plugins = activePlugins.includes( 'jetpack' ) ? 'installed-wcs' : 'installed'; await updateProfileItems( { plugins } ); if ( ! isProfileItemsError ) { recordEvent( 'storeprofiler_welcome_clicked', { get_started: true, plugins } ); goToNextStep(); } else { createNotice( 'error', __( 'There was a problem updating your preferences.', 'woocommerce-admin' ) ); } } renderBenefit( benefit ) { const { description, icon, title } = benefit; return (
{ description }
{ interpolateComponents( { mixedString: sprintf( __( 'Simplify and enhance the setup of your store with the free features and benefits offered by ' + '{{strong}}%s{{/strong}}.', 'woocommerce-admin' ), pluginNames ), components: { strong: , }, } ) }
{ interpolateComponents( { mixedString: __( 'By connecting your site you agree to our fascinating {{tosLink}}Terms of Service{{/tosLink}} and to ' + '{{detailsLink}}share details{{/detailsLink}} with WordPress.com. ', 'woocommerce-admin' ), components: { tosLink: , detailsLink: ( ), }, } ) }