2020-03-20 16:48:11 +00:00
/ * *
* External dependencies
* /
import { _ _ } from '@wordpress/i18n' ;
import { Placeholder , Button , Notice } from 'wordpress-components' ;
import { Icon , card } from '@woocommerce/icons' ;
import { ADMIN _URL } from '@woocommerce/settings' ;
2020-04-01 09:27:53 +00:00
import { useEditorContext } from '@woocommerce/base-context' ;
2020-03-20 16:48:11 +00:00
import classnames from 'classnames' ;
/ * *
* Internal dependencies
* /
import './style.scss' ;
/ * *
* Render content when no payment methods are found depending on context .
* /
const NoPaymentMethods = ( ) => {
2020-04-01 09:27:53 +00:00
const { isEditor } = useEditorContext ( ) ;
2020-03-20 16:48:11 +00:00
return isEditor ? (
< NoPaymentMethodsPlaceholder / >
) : (
< NoPaymentMethodsNotice / >
) ;
} ;
/ * *
* Renders a placeholder in the editor .
* /
const NoPaymentMethodsPlaceholder = ( ) => {
return (
< Placeholder
icon = { < Icon srcElement = { card } / > }
label = { _ _ ( 'Payment methods' , 'woo-gutenberg-products-block' ) }
2020-04-06 15:35:09 +00:00
className = "wc-block-checkout__no-payment-methods-placeholder"
2020-03-20 16:48:11 +00:00
>
2020-04-06 15:35:09 +00:00
< span className = "wc-block-checkout__no-payment-methods-placeholder-description" >
2020-03-20 16:48:11 +00:00
{ _ _ (
2022-01-11 10:53:38 +00:00
'Your store does not have any payment methods configured that support the checkout block. Once you have configured a compatible payment method it will be shown here.' ,
2020-03-20 16:48:11 +00:00
'woo-gutenberg-products-block'
) }
< / s p a n >
< Button
2020-12-21 16:03:54 +00:00
isSecondary
2020-03-20 16:48:11 +00:00
href = { ` ${ ADMIN _URL } admin.php?page=wc-settings&tab=checkout ` }
target = "_blank"
rel = "noopener noreferrer"
>
{ _ _ (
'Configure Payment Methods' ,
'woo-gutenberg-products-block'
) }
< / B u t t o n >
< / P l a c e h o l d e r >
) ;
} ;
/ * *
* Renders a notice on the frontend .
* /
const NoPaymentMethodsNotice = ( ) => {
return (
< Notice
isDismissible = { false }
className = { classnames (
'wc-block-checkout__no-payment-methods-notice' ,
'woocommerce-message' ,
'woocommerce-error'
) }
>
{ _ _ (
'There are no payment methods available. This may be an error on our side. Please contact us if you need any help placing your order.' ,
'woo-gutenberg-products-block'
) }
< / N o t i c e >
) ;
} ;
export default NoPaymentMethods ;