2020-01-06 22:28:09 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { useExpressPaymentMethods } from '@woocommerce/base-hooks';
|
2020-04-06 12:18:35 +00:00
|
|
|
import { StoreNoticesProvider } from '@woocommerce/base-context';
|
2020-06-05 10:00:19 +00:00
|
|
|
import Title from '@woocommerce/base-components/title';
|
2020-01-06 22:28:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
<>
|
2020-06-05 12:18:16 +00:00
|
|
|
<div className="wc-block-components-express-checkout">
|
2020-06-05 10:00:19 +00:00
|
|
|
<Title
|
2020-06-05 12:18:16 +00:00
|
|
|
className="wc-block-components-express-checkout__title"
|
2020-06-05 10:00:19 +00:00
|
|
|
headingLevel="2"
|
|
|
|
>
|
2020-01-06 22:28:09 +00:00
|
|
|
{ __( 'Express checkout', 'woo-gutenberg-products-block' ) }
|
2020-06-05 10:00:19 +00:00
|
|
|
</Title>
|
2020-06-05 12:18:16 +00:00
|
|
|
<div className="wc-block-components-express-checkout__content">
|
2020-04-06 12:18:35 +00:00
|
|
|
<StoreNoticesProvider context="wc/express-payment-area">
|
|
|
|
{ children }
|
|
|
|
</StoreNoticesProvider>
|
2020-03-09 15:49:01 +00:00
|
|
|
</div>
|
2020-01-06 22:28:09 +00:00
|
|
|
</div>
|
2020-06-05 12:18:16 +00:00
|
|
|
<div className="wc-block-components-express-checkout-continue-rule">
|
2020-03-09 15:49:01 +00:00
|
|
|
{ __( 'Or continue below', 'woo-gutenberg-products-block' ) }
|
|
|
|
</div>
|
|
|
|
</>
|
2020-01-06 22:28:09 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const ExpressCheckoutFormControl = () => {
|
|
|
|
const { paymentMethods, isInitialized } = useExpressPaymentMethods();
|
|
|
|
|
|
|
|
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;
|