2020-01-06 22:28:09 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { useExpressPaymentMethods } from '@woocommerce/base-hooks';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import ExpressPaymentMethods from './express-payment-methods';
|
2020-03-27 20:56:48 +00:00
|
|
|
import './style.scss';
|
2020-01-06 22:28:09 +00:00
|
|
|
|
|
|
|
const ExpressCheckoutContainer = ( { children } ) => {
|
|
|
|
return (
|
2020-03-09 15:49:01 +00:00
|
|
|
<>
|
|
|
|
<div className="wc-block-component-express-checkout">
|
|
|
|
<div className="wc-block-component-express-checkout__title">
|
2020-01-06 22:28:09 +00:00
|
|
|
{ __( 'Express checkout', 'woo-gutenberg-products-block' ) }
|
2020-03-09 15:49:01 +00:00
|
|
|
</div>
|
|
|
|
<div className="wc-block-component-express-checkout__content">
|
|
|
|
{ children }
|
|
|
|
</div>
|
2020-01-06 22:28:09 +00:00
|
|
|
</div>
|
2020-03-09 15:49:01 +00:00
|
|
|
<div className="wc-block-component-express-checkout-continue-rule">
|
|
|
|
{ __( 'Or continue below', 'woo-gutenberg-products-block' ) }
|
|
|
|
</div>
|
|
|
|
</>
|
2020-01-06 22:28:09 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const ExpressCheckoutFormControl = () => {
|
|
|
|
const { paymentMethods, isInitialized } = useExpressPaymentMethods();
|
|
|
|
|
|
|
|
// determine whether we even show this
|
|
|
|
// @todo if in the editor we probably would want to show a placeholder maybe?
|
|
|
|
if (
|
|
|
|
! isInitialized ||
|
|
|
|
( isInitialized && Object.keys( paymentMethods ).length === 0 )
|
|
|
|
) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ExpressCheckoutContainer>
|
|
|
|
<p>
|
|
|
|
{ __(
|
|
|
|
'In a hurry? Use one of our express checkout options below:',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
) }
|
|
|
|
</p>
|
|
|
|
<ExpressPaymentMethods />
|
|
|
|
</ExpressCheckoutContainer>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ExpressCheckoutFormControl;
|