2019-06-26 02:22:44 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
2019-12-30 10:11:50 +00:00
|
|
|
import apiFetch from '@wordpress/api-fetch';
|
2019-06-26 02:22:44 +00:00
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
|
|
|
import { compose } from '@wordpress/compose';
|
|
|
|
import { decodeEntities } from '@wordpress/html-entities';
|
2019-06-28 07:42:20 +00:00
|
|
|
import Gridicon from 'gridicons';
|
2019-12-02 17:39:22 +00:00
|
|
|
import { Button, TabPanel, Tooltip } from '@wordpress/components';
|
2019-06-26 02:22:44 +00:00
|
|
|
import { withDispatch } from '@wordpress/data';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce dependencies
|
|
|
|
*/
|
|
|
|
import { Card, H } from '@woocommerce/components';
|
2019-12-30 10:11:50 +00:00
|
|
|
import { getSetting, setSetting } from '@woocommerce/wc-admin-settings';
|
2020-05-28 08:51:40 +00:00
|
|
|
import { ONBOARDING_STORE_NAME } from '@woocommerce/data';
|
2019-06-26 02:22:44 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-14 14:35:55 +00:00
|
|
|
* Internal dependencies
|
2019-06-26 02:22:44 +00:00
|
|
|
*/
|
|
|
|
import withSelect from 'wc-api/with-select';
|
|
|
|
import './style.scss';
|
2019-07-01 18:13:29 +00:00
|
|
|
import { recordEvent } from 'lib/tracks';
|
2019-07-08 02:54:26 +00:00
|
|
|
import ThemeUploader from './uploader';
|
2019-08-01 23:27:38 +00:00
|
|
|
import ThemePreview from './preview';
|
2019-12-30 10:11:50 +00:00
|
|
|
import { getPriceValue } from 'dashboard/utils';
|
2019-06-26 02:22:44 +00:00
|
|
|
|
|
|
|
class Theme extends Component {
|
|
|
|
constructor() {
|
|
|
|
super( ...arguments );
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
activeTab: 'all',
|
2019-11-01 02:04:54 +00:00
|
|
|
chosen: null,
|
2019-08-01 23:27:38 +00:00
|
|
|
demo: null,
|
2019-07-08 02:54:26 +00:00
|
|
|
uploadedThemes: [],
|
2019-06-26 02:22:44 +00:00
|
|
|
};
|
|
|
|
|
2019-07-08 02:54:26 +00:00
|
|
|
this.handleUploadComplete = this.handleUploadComplete.bind( this );
|
2019-06-26 02:22:44 +00:00
|
|
|
this.onChoose = this.onChoose.bind( this );
|
2019-08-01 23:27:38 +00:00
|
|
|
this.onClosePreview = this.onClosePreview.bind( this );
|
2019-06-26 02:22:44 +00:00
|
|
|
this.onSelectTab = this.onSelectTab.bind( this );
|
|
|
|
this.openDemo = this.openDemo.bind( this );
|
2019-12-31 19:55:00 +00:00
|
|
|
this.skipStep = this.skipStep.bind( this );
|
2019-06-26 02:22:44 +00:00
|
|
|
}
|
|
|
|
|
2019-11-06 14:41:38 +00:00
|
|
|
componentDidUpdate( prevProps ) {
|
2020-05-28 08:51:40 +00:00
|
|
|
const { isError, isUpdatingProfileItems, createNotice } = this.props;
|
2019-11-06 14:41:38 +00:00
|
|
|
const { chosen } = this.state;
|
2019-12-20 12:58:38 +00:00
|
|
|
const isRequestSuccessful =
|
2020-05-28 08:51:40 +00:00
|
|
|
! isUpdatingProfileItems &&
|
|
|
|
prevProps.isUpdatingProfileItems &&
|
2020-02-14 02:23:21 +00:00
|
|
|
! isError &&
|
|
|
|
chosen;
|
|
|
|
const isRequestError =
|
2020-05-28 08:51:40 +00:00
|
|
|
! isUpdatingProfileItems && prevProps.isRequesting && isError;
|
2019-11-06 14:41:38 +00:00
|
|
|
|
2019-12-20 12:58:38 +00:00
|
|
|
if ( isRequestSuccessful ) {
|
|
|
|
/* eslint-disable react/no-did-update-set-state */
|
|
|
|
this.setState( { chosen: null } );
|
|
|
|
/* eslint-enable react/no-did-update-set-state */
|
|
|
|
this.props.goToNextStep();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isRequestError ) {
|
|
|
|
/* eslint-disable react/no-did-update-set-state */
|
|
|
|
this.setState( { chosen: null } );
|
|
|
|
/* eslint-enable react/no-did-update-set-state */
|
|
|
|
createNotice(
|
|
|
|
'error',
|
2020-02-14 02:23:21 +00:00
|
|
|
__(
|
|
|
|
'There was a problem selecting your store theme.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
)
|
2019-12-20 12:58:38 +00:00
|
|
|
);
|
2019-11-06 14:41:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-30 10:11:50 +00:00
|
|
|
onChoose( theme, location = '' ) {
|
2019-11-06 14:41:38 +00:00
|
|
|
const { updateProfileItems } = this.props;
|
2020-04-21 12:13:04 +00:00
|
|
|
const { is_installed: isInstalled, price, slug } = theme;
|
2019-12-30 10:11:50 +00:00
|
|
|
const { activeTheme = '' } = getSetting( 'onboarding', {} );
|
|
|
|
|
|
|
|
this.setState( { chosen: slug } );
|
2020-02-14 02:23:21 +00:00
|
|
|
recordEvent( 'storeprofiler_store_theme_choose', {
|
|
|
|
theme: slug,
|
|
|
|
location,
|
|
|
|
} );
|
2019-12-30 10:11:50 +00:00
|
|
|
|
2020-04-21 12:13:04 +00:00
|
|
|
if ( slug !== activeTheme && getPriceValue( price ) <= 0 ) {
|
|
|
|
if ( isInstalled ) {
|
|
|
|
this.activateTheme( slug );
|
|
|
|
} else {
|
|
|
|
this.installTheme( slug );
|
|
|
|
}
|
2019-12-30 10:11:50 +00:00
|
|
|
} else {
|
|
|
|
updateProfileItems( { theme: slug } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
installTheme( slug ) {
|
|
|
|
const { createNotice } = this.props;
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
apiFetch( {
|
|
|
|
path: '/wc-admin/onboarding/themes/install?theme=' + slug,
|
|
|
|
method: 'POST',
|
|
|
|
} )
|
2020-04-21 12:13:04 +00:00
|
|
|
.then( ( response ) => {
|
|
|
|
createNotice(
|
|
|
|
'success',
|
|
|
|
sprintf(
|
|
|
|
__(
|
|
|
|
'%s was installed on your site.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
response.name
|
|
|
|
)
|
|
|
|
);
|
2019-12-30 10:11:50 +00:00
|
|
|
this.activateTheme( slug );
|
|
|
|
} )
|
2020-02-14 02:23:21 +00:00
|
|
|
.catch( ( response ) => {
|
2019-12-30 10:11:50 +00:00
|
|
|
this.setState( { chosen: null } );
|
|
|
|
createNotice( 'error', response.message );
|
|
|
|
} );
|
|
|
|
}
|
2019-06-26 02:22:44 +00:00
|
|
|
|
2019-12-30 10:11:50 +00:00
|
|
|
activateTheme( slug ) {
|
|
|
|
const { createNotice, updateProfileItems } = this.props;
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
apiFetch( {
|
|
|
|
path: '/wc-admin/onboarding/themes/activate?theme=' + slug,
|
|
|
|
method: 'POST',
|
|
|
|
} )
|
|
|
|
.then( ( response ) => {
|
2019-12-30 10:11:50 +00:00
|
|
|
createNotice(
|
|
|
|
'success',
|
|
|
|
sprintf(
|
2020-02-14 02:23:21 +00:00
|
|
|
__(
|
2020-04-21 12:13:04 +00:00
|
|
|
'%s was activated on your site.',
|
2020-02-14 02:23:21 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-12-30 10:11:50 +00:00
|
|
|
response.name
|
|
|
|
)
|
|
|
|
);
|
|
|
|
setSetting( 'onboarding', {
|
|
|
|
...getSetting( 'onboarding', {} ),
|
|
|
|
activeTheme: response.slug,
|
|
|
|
} );
|
|
|
|
updateProfileItems( { theme: slug } );
|
|
|
|
} )
|
2020-02-14 02:23:21 +00:00
|
|
|
.catch( ( response ) => {
|
2019-12-30 10:11:50 +00:00
|
|
|
this.setState( { chosen: null } );
|
|
|
|
createNotice( 'error', response.message );
|
|
|
|
} );
|
2019-06-26 02:22:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 23:27:38 +00:00
|
|
|
onClosePreview() {
|
|
|
|
const { demo } = this.state;
|
2020-02-14 02:23:21 +00:00
|
|
|
recordEvent( 'storeprofiler_store_theme_demo_close', {
|
|
|
|
theme: demo.slug,
|
|
|
|
} );
|
2019-08-01 23:27:38 +00:00
|
|
|
document.body.classList.remove( 'woocommerce-theme-preview-active' );
|
|
|
|
this.setState( { demo: null } );
|
|
|
|
}
|
2019-07-01 18:13:29 +00:00
|
|
|
|
2019-08-01 23:27:38 +00:00
|
|
|
openDemo( theme ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
recordEvent( 'storeprofiler_store_theme_live_demo', {
|
|
|
|
theme: theme.slug,
|
|
|
|
} );
|
2019-08-01 23:27:38 +00:00
|
|
|
document.body.classList.add( 'woocommerce-theme-preview-active' );
|
|
|
|
this.setState( { demo: theme } );
|
2019-06-26 02:22:44 +00:00
|
|
|
}
|
|
|
|
|
2019-12-31 19:55:00 +00:00
|
|
|
skipStep() {
|
|
|
|
const { activeTheme = '' } = getSetting( 'onboarding', {} );
|
|
|
|
recordEvent( 'storeprofiler_store_theme_skip_step', { activeTheme } );
|
|
|
|
this.props.goToNextStep();
|
|
|
|
}
|
|
|
|
|
2019-06-26 02:22:44 +00:00
|
|
|
renderTheme( theme ) {
|
2020-04-21 12:13:04 +00:00
|
|
|
const {
|
|
|
|
demo_url: demoUrl,
|
|
|
|
has_woocommerce_support: hasSupport,
|
|
|
|
image,
|
|
|
|
slug,
|
|
|
|
title,
|
|
|
|
} = theme;
|
2019-11-01 02:04:54 +00:00
|
|
|
const { chosen } = this.state;
|
2020-01-14 10:19:09 +00:00
|
|
|
const { activeTheme = '' } = getSetting( 'onboarding', {} );
|
2019-06-26 02:22:44 +00:00
|
|
|
|
|
|
|
return (
|
2020-06-15 22:32:36 +00:00
|
|
|
<Card className="woocommerce-profile-wizard__theme" key={ slug }>
|
2019-06-26 02:22:44 +00:00
|
|
|
{ image && (
|
2019-11-19 01:18:22 +00:00
|
|
|
<div
|
|
|
|
className="woocommerce-profile-wizard__theme-image"
|
|
|
|
style={ { backgroundImage: `url(${ image })` } }
|
|
|
|
role="img"
|
|
|
|
aria-label={ title }
|
|
|
|
/>
|
2019-06-26 02:22:44 +00:00
|
|
|
) }
|
|
|
|
<div className="woocommerce-profile-wizard__theme-details">
|
2019-06-28 07:42:20 +00:00
|
|
|
<H className="woocommerce-profile-wizard__theme-name">
|
|
|
|
{ title }
|
2020-02-14 02:23:21 +00:00
|
|
|
{ ! hasSupport && (
|
2019-06-28 07:42:20 +00:00
|
|
|
<Tooltip
|
2020-02-14 02:23:21 +00:00
|
|
|
text={ __(
|
|
|
|
'This theme does not support WooCommerce.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-06-28 07:42:20 +00:00
|
|
|
>
|
|
|
|
<span>
|
2020-02-14 02:23:21 +00:00
|
|
|
<Gridicon
|
|
|
|
icon="info"
|
|
|
|
role="img"
|
|
|
|
aria-hidden="true"
|
|
|
|
focusable="false"
|
|
|
|
/>
|
2019-06-28 07:42:20 +00:00
|
|
|
</span>
|
|
|
|
</Tooltip>
|
|
|
|
) }
|
|
|
|
</H>
|
|
|
|
<p className="woocommerce-profile-wizard__theme-status">
|
|
|
|
{ this.getThemeStatus( theme ) }
|
2019-06-26 02:22:44 +00:00
|
|
|
</p>
|
|
|
|
<div className="woocommerce-profile-wizard__theme-actions">
|
2020-01-14 10:19:09 +00:00
|
|
|
{ slug === activeTheme ? (
|
|
|
|
<Button
|
|
|
|
isPrimary
|
|
|
|
onClick={ () => this.onChoose( theme, 'card' ) }
|
|
|
|
isBusy={ chosen === slug }
|
|
|
|
>
|
2020-02-14 02:23:21 +00:00
|
|
|
{ __(
|
|
|
|
'Continue with my active theme',
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2020-01-14 10:19:09 +00:00
|
|
|
</Button>
|
|
|
|
) : (
|
|
|
|
<Button
|
2020-06-11 19:22:20 +00:00
|
|
|
isSecondary
|
2020-01-14 10:19:09 +00:00
|
|
|
onClick={ () => this.onChoose( theme, 'card' ) }
|
|
|
|
isBusy={ chosen === slug }
|
|
|
|
>
|
|
|
|
{ __( 'Choose', 'woocommerce-admin' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
2020-02-14 02:23:21 +00:00
|
|
|
{ demoUrl && (
|
|
|
|
<Button
|
|
|
|
isTertiary
|
|
|
|
onClick={ () => this.openDemo( theme ) }
|
|
|
|
>
|
2020-01-14 10:19:09 +00:00
|
|
|
{ __( 'Live demo', 'woocommerce-admin' ) }
|
2019-06-28 07:42:20 +00:00
|
|
|
</Button>
|
|
|
|
) }
|
2019-06-26 02:22:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-28 07:42:20 +00:00
|
|
|
getThemeStatus( theme ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
const { is_installed: isInstalled, price, slug } = theme;
|
2019-10-07 11:51:25 +00:00
|
|
|
const { activeTheme = '' } = getSetting( 'onboarding', {} );
|
2019-06-28 07:42:20 +00:00
|
|
|
|
|
|
|
if ( activeTheme === slug ) {
|
|
|
|
return __( 'Currently active theme', 'woocommerce-admin' );
|
|
|
|
}
|
2020-02-14 02:23:21 +00:00
|
|
|
if ( isInstalled ) {
|
2019-06-28 07:42:20 +00:00
|
|
|
return __( 'Installed', 'woocommerce-admin' );
|
2019-12-30 10:11:50 +00:00
|
|
|
} else if ( getPriceValue( price ) <= 0 ) {
|
2019-06-28 07:42:20 +00:00
|
|
|
return __( 'Free', 'woocommerce-admin' );
|
|
|
|
}
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
return sprintf(
|
|
|
|
__( '%s per year', 'woocommerce-admin' ),
|
|
|
|
decodeEntities( price )
|
|
|
|
);
|
2019-06-28 07:42:20 +00:00
|
|
|
}
|
|
|
|
|
2019-12-31 19:55:00 +00:00
|
|
|
doesActiveThemeSupportWooCommerce() {
|
|
|
|
const { activeTheme = '' } = getSetting( 'onboarding', {} );
|
|
|
|
const allThemes = this.getThemes();
|
2020-02-14 02:23:21 +00:00
|
|
|
const currentTheme = allThemes.find(
|
|
|
|
( theme ) => theme.slug === activeTheme
|
|
|
|
);
|
2019-12-31 19:55:00 +00:00
|
|
|
return currentTheme && currentTheme.has_woocommerce_support;
|
|
|
|
}
|
|
|
|
|
2019-06-26 02:22:44 +00:00
|
|
|
onSelectTab( tab ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
recordEvent( 'storeprofiler_store_theme_navigate', {
|
|
|
|
navigation: tab,
|
|
|
|
} );
|
2019-06-26 02:22:44 +00:00
|
|
|
this.setState( { activeTab: tab } );
|
|
|
|
}
|
|
|
|
|
|
|
|
getPriceValue( string ) {
|
|
|
|
return Number( decodeEntities( string ).replace( /[^0-9.-]+/g, '' ) );
|
|
|
|
}
|
|
|
|
|
2019-12-31 19:55:00 +00:00
|
|
|
getThemes( activeTab = 'all' ) {
|
|
|
|
const { uploadedThemes } = this.state;
|
2020-02-14 02:23:21 +00:00
|
|
|
const { activeTheme = '', themes = [] } = getSetting(
|
|
|
|
'onboarding',
|
|
|
|
{}
|
|
|
|
);
|
2020-01-24 02:11:36 +00:00
|
|
|
const allThemes = [
|
2020-02-14 02:23:21 +00:00
|
|
|
...themes.filter(
|
|
|
|
( theme ) =>
|
2020-05-08 07:12:37 +00:00
|
|
|
theme &&
|
|
|
|
( theme.has_woocommerce_support ||
|
|
|
|
theme.slug === activeTheme )
|
2020-02-14 02:23:21 +00:00
|
|
|
),
|
2020-01-24 02:11:36 +00:00
|
|
|
...uploadedThemes,
|
|
|
|
];
|
2019-06-26 02:22:44 +00:00
|
|
|
|
|
|
|
switch ( activeTab ) {
|
|
|
|
case 'paid':
|
2020-02-14 02:23:21 +00:00
|
|
|
return allThemes.filter(
|
|
|
|
( theme ) => getPriceValue( theme.price ) > 0
|
|
|
|
);
|
2019-06-26 02:22:44 +00:00
|
|
|
case 'free':
|
2020-02-14 02:23:21 +00:00
|
|
|
return allThemes.filter(
|
|
|
|
( theme ) => getPriceValue( theme.price ) <= 0
|
|
|
|
);
|
2019-06-26 02:22:44 +00:00
|
|
|
case 'all':
|
|
|
|
default:
|
2019-07-08 02:54:26 +00:00
|
|
|
return allThemes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleUploadComplete( upload ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
if ( upload.status === 'success' && upload.theme_data ) {
|
2019-07-08 02:54:26 +00:00
|
|
|
this.setState( {
|
2020-02-14 02:23:21 +00:00
|
|
|
uploadedThemes: [
|
|
|
|
...this.state.uploadedThemes,
|
|
|
|
upload.theme_data,
|
|
|
|
],
|
2019-07-08 02:54:26 +00:00
|
|
|
} );
|
2019-08-01 23:27:38 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
recordEvent( 'storeprofiler_store_theme_upload', {
|
|
|
|
theme: upload.theme_data.slug,
|
|
|
|
} );
|
2019-06-26 02:22:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-12-31 19:55:00 +00:00
|
|
|
const { activeTab, chosen, demo } = this.state;
|
|
|
|
const themes = this.getThemes( activeTab );
|
|
|
|
const activeThemeSupportsWooCommerce = this.doesActiveThemeSupportWooCommerce();
|
2019-06-26 02:22:44 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<H className="woocommerce-profile-wizard__header-title">
|
|
|
|
{ __( 'Choose a theme', 'woocommerce-admin' ) }
|
|
|
|
</H>
|
|
|
|
<H className="woocommerce-profile-wizard__header-subtitle">
|
2019-08-08 18:41:26 +00:00
|
|
|
{ __(
|
|
|
|
"Choose how your store appears to customers. And don't worry, you can always switch themes and edit them later.",
|
|
|
|
'woocommerce-admin'
|
|
|
|
) }
|
2019-06-26 02:22:44 +00:00
|
|
|
</H>
|
|
|
|
<TabPanel
|
|
|
|
className="woocommerce-profile-wizard__themes-tab-panel"
|
|
|
|
activeClass="is-active"
|
|
|
|
onSelect={ this.onSelectTab }
|
|
|
|
tabs={ [
|
|
|
|
{
|
|
|
|
name: 'all',
|
|
|
|
title: __( 'All themes', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'paid',
|
|
|
|
title: __( 'Paid themes', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'free',
|
|
|
|
title: __( 'Free themes', 'woocommerce-admin' ),
|
|
|
|
},
|
|
|
|
] }
|
|
|
|
>
|
|
|
|
{ () => (
|
|
|
|
<div className="woocommerce-profile-wizard__themes">
|
2020-02-14 02:23:21 +00:00
|
|
|
{ themes &&
|
|
|
|
themes.map( ( theme ) =>
|
|
|
|
this.renderTheme( theme )
|
|
|
|
) }
|
|
|
|
<ThemeUploader
|
|
|
|
onUploadComplete={ this.handleUploadComplete }
|
|
|
|
/>
|
2019-06-26 02:22:44 +00:00
|
|
|
</div>
|
|
|
|
) }
|
|
|
|
</TabPanel>
|
2019-08-01 23:27:38 +00:00
|
|
|
{ demo && (
|
2019-11-01 02:04:54 +00:00
|
|
|
<ThemePreview
|
|
|
|
theme={ demo }
|
2020-06-15 22:32:36 +00:00
|
|
|
onChoose={ () => this.onChoose( demo, 'card' ) }
|
2019-11-01 02:04:54 +00:00
|
|
|
onClose={ this.onClosePreview }
|
|
|
|
isBusy={ chosen === demo.slug }
|
|
|
|
/>
|
2019-08-01 23:27:38 +00:00
|
|
|
) }
|
2019-12-31 19:55:00 +00:00
|
|
|
{ activeThemeSupportsWooCommerce && (
|
2020-07-22 23:37:40 +00:00
|
|
|
<p className="woocommerce-profile-wizard__themes-skip-this-step">
|
2019-12-31 19:55:00 +00:00
|
|
|
<Button
|
|
|
|
isLink
|
|
|
|
className="woocommerce-profile-wizard__skip"
|
|
|
|
onClick={ () => this.skipStep() }
|
|
|
|
>
|
|
|
|
{ __( 'Skip this step', 'woocommerce-admin' ) }
|
|
|
|
</Button>
|
|
|
|
</p>
|
|
|
|
) }
|
2019-06-26 02:22:44 +00:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
2020-02-14 02:23:21 +00:00
|
|
|
withSelect( ( select ) => {
|
|
|
|
const {
|
|
|
|
getProfileItems,
|
2020-05-28 08:51:40 +00:00
|
|
|
getOnboardingError,
|
|
|
|
isOnboardingRequesting,
|
|
|
|
} = select( ONBOARDING_STORE_NAME );
|
2019-06-26 02:22:44 +00:00
|
|
|
|
2019-11-01 02:04:54 +00:00
|
|
|
return {
|
2020-05-28 08:51:40 +00:00
|
|
|
isError: Boolean( getOnboardingError( 'updateProfileItems' ) ),
|
|
|
|
isUpdatingProfileItems: isOnboardingRequesting(
|
|
|
|
'updateProfileItems'
|
|
|
|
),
|
2019-11-01 02:04:54 +00:00
|
|
|
profileItems: getProfileItems(),
|
|
|
|
};
|
2019-06-26 02:22:44 +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 );
|
2019-07-23 03:26:46 +00:00
|
|
|
const { createNotice } = dispatch( 'core/notices' );
|
2019-06-26 02:22:44 +00:00
|
|
|
|
|
|
|
return {
|
2019-07-23 03:26:46 +00:00
|
|
|
createNotice,
|
2019-06-26 02:22:44 +00:00
|
|
|
updateProfileItems,
|
|
|
|
};
|
|
|
|
} )
|
|
|
|
)( Theme );
|