2019-12-03 13:57:56 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2019-12-16 14:59:16 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2020-01-16 14:50:48 +00:00
|
|
|
import { Disabled } from '@wordpress/components';
|
|
|
|
import { Fragment } from '@wordpress/element';
|
2019-12-10 15:41:57 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-12-16 14:59:16 +00:00
|
|
|
import { withFeedbackPrompt } from '@woocommerce/block-hocs';
|
2020-01-16 14:50:48 +00:00
|
|
|
import ViewSwitcher from '@woocommerce/block-components/view-switcher';
|
2020-02-18 23:06:37 +00:00
|
|
|
import { previewCart } from '@woocommerce/resource-previews';
|
2019-12-05 21:08:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2019-12-10 15:41:57 +00:00
|
|
|
import FullCart from './full-cart';
|
|
|
|
import EmptyCart from './empty-cart';
|
2019-12-03 13:57:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component to handle edit mode of "Cart Block".
|
|
|
|
*/
|
2019-12-10 15:41:57 +00:00
|
|
|
const CartEditor = ( { className } ) => {
|
2019-12-05 21:08:48 +00:00
|
|
|
return (
|
2019-12-10 15:41:57 +00:00
|
|
|
<div className={ className }>
|
2020-01-16 14:50:48 +00:00
|
|
|
<ViewSwitcher
|
|
|
|
label={ __( 'Edit', 'woo-gutenberg-products-block' ) }
|
|
|
|
views={ [
|
|
|
|
{
|
|
|
|
value: 'full',
|
|
|
|
name: __( 'Full Cart', 'woo-gutenberg-products-block' ),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'empty',
|
|
|
|
name: __(
|
|
|
|
'Empty Cart',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
] }
|
|
|
|
defaultView={ 'full' }
|
|
|
|
render={ ( currentView ) => (
|
|
|
|
<Fragment>
|
|
|
|
{ currentView === 'full' && (
|
|
|
|
<Disabled>
|
2020-02-18 23:06:37 +00:00
|
|
|
<FullCart
|
|
|
|
cartItems={ previewCart.items }
|
|
|
|
cartTotals={ previewCart.totals }
|
|
|
|
/>
|
2020-01-16 14:50:48 +00:00
|
|
|
</Disabled>
|
|
|
|
) }
|
|
|
|
<EmptyCart hidden={ currentView === 'full' } />
|
|
|
|
</Fragment>
|
|
|
|
) }
|
|
|
|
/>
|
2019-12-10 15:41:57 +00:00
|
|
|
</div>
|
2019-12-05 21:08:48 +00:00
|
|
|
);
|
2019-12-03 13:57:56 +00:00
|
|
|
};
|
|
|
|
|
2019-12-10 15:41:57 +00:00
|
|
|
CartEditor.propTypes = {
|
|
|
|
className: PropTypes.string,
|
|
|
|
};
|
2019-12-03 13:57:56 +00:00
|
|
|
|
2019-12-16 14:59:16 +00:00
|
|
|
export default withFeedbackPrompt(
|
|
|
|
__(
|
|
|
|
'We are currently working on improving our cart and providing merchants with tools and options to customize their cart to their stores needs.',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
)
|
|
|
|
)( CartEditor );
|