2019-12-03 14:12:46 +00:00
/ * *
* External dependencies
* /
2019-12-16 14:59:16 +00:00
import { _ _ } from '@wordpress/i18n' ;
import { withFeedbackPrompt } from '@woocommerce/block-hocs' ;
2020-02-26 15:50:53 +00:00
import { previewShippingRates } from '@woocommerce/resource-previews' ;
import { SHIPPING _METHODS _EXIST } from '@woocommerce/block-settings' ;
2020-03-04 15:13:38 +00:00
import { InspectorControls } from '@wordpress/block-editor' ;
import { PanelBody , ToggleControl } from '@wordpress/components' ;
2019-12-03 14:12:46 +00:00
/ * *
* Internal dependencies
* /
import Block from './block.js' ;
2019-12-06 13:18:55 +00:00
import './editor.scss' ;
2019-12-03 14:12:46 +00:00
2020-03-04 15:13:38 +00:00
const CheckoutEditor = ( { attributes , setAttributes } ) => {
const { className , useShippingAsBilling } = attributes ;
2019-12-16 22:13:41 +00:00
// @todo: wrap Block with Disabled once you finish building the form
2019-12-03 14:12:46 +00:00
return (
< div className = { className } >
2020-03-04 15:13:38 +00:00
< InspectorControls >
< PanelBody
title = { _ _ (
'Billing address' ,
'woo-gutenberg-products-block'
) }
>
< p className = "wc-block-checkout__controls-text" >
{ _ _ (
'Reduce the number of fields required to checkout.' ,
'woo-gutenberg-products-block'
) }
< / p >
< ToggleControl
label = { _ _ (
'Use the shipping address as the billing address' ,
'woo-gutenberg-products-block'
) }
checked = { useShippingAsBilling }
onChange = { ( ) =>
setAttributes ( {
useShippingAsBilling : ! useShippingAsBilling ,
} )
}
/ >
< / P a n e l B o d y >
< / I n s p e c t o r C o n t r o l s >
2020-02-26 15:50:53 +00:00
< Block
attributes = { attributes }
isEditor = { true }
shippingRates = {
SHIPPING _METHODS _EXIST ? previewShippingRates : [ ]
}
/ >
2019-12-03 14:12:46 +00:00
< / d i v >
) ;
} ;
2019-12-16 14:59:16 +00:00
export default withFeedbackPrompt (
_ _ (
'We are currently working on improving our checkout and providing merchants with tools and options to customize their checkout to their stores needs.' ,
'woo-gutenberg-products-block'
)
) ( CheckoutEditor ) ;