Use noticeContexts from useEmitResponse instead of hardcoded values (https://github.com/woocommerce/woocommerce-blocks/pull/3161)
This commit is contained in:
parent
d641d2e1a4
commit
261844d05b
|
@ -2,7 +2,10 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useExpressPaymentMethods } from '@woocommerce/base-hooks';
|
||||
import {
|
||||
useEmitResponse,
|
||||
useExpressPaymentMethods,
|
||||
} from '@woocommerce/base-hooks';
|
||||
import { StoreNoticesProvider } from '@woocommerce/base-context';
|
||||
|
||||
/**
|
||||
|
@ -13,6 +16,7 @@ import './style.scss';
|
|||
|
||||
const CartExpressPayment = () => {
|
||||
const { paymentMethods, isInitialized } = useExpressPaymentMethods();
|
||||
const { noticeContexts } = useEmitResponse();
|
||||
|
||||
if (
|
||||
! isInitialized ||
|
||||
|
@ -25,7 +29,9 @@ const CartExpressPayment = () => {
|
|||
<>
|
||||
<div className="wc-block-components-express-payment wc-block-components-express-payment--cart">
|
||||
<div className="wc-block-components-express-payment__content">
|
||||
<StoreNoticesProvider context="wc/express-payment-area">
|
||||
<StoreNoticesProvider
|
||||
context={ noticeContexts.EXPRESS_PAYMENTS }
|
||||
>
|
||||
<ExpressPaymentMethods />
|
||||
</StoreNoticesProvider>
|
||||
</div>
|
||||
|
|
|
@ -195,17 +195,17 @@ export const PaymentMethodDataProvider = ( { children } ) => {
|
|||
( message ) => {
|
||||
if ( message ) {
|
||||
addErrorNotice( message, {
|
||||
context: 'wc/express-payment-area',
|
||||
context: noticeContexts.EXPRESS_PAYMENTS,
|
||||
id: 'wc-express-payment-error',
|
||||
} );
|
||||
} else {
|
||||
removeNotice(
|
||||
'wc-express-payment-error',
|
||||
'wc/express-payment-area'
|
||||
noticeContexts.EXPRESS_PAYMENTS
|
||||
);
|
||||
}
|
||||
},
|
||||
[ addErrorNotice, removeNotice ]
|
||||
[ addErrorNotice, noticeContexts.EXPRESS_PAYMENTS, removeNotice ]
|
||||
);
|
||||
// ensure observers are always current.
|
||||
useEffect( () => {
|
||||
|
|
|
@ -7,13 +7,18 @@ import {
|
|||
useCheckoutContext,
|
||||
StoreNoticesProvider,
|
||||
} from '@woocommerce/base-context';
|
||||
import { usePaymentMethods, useStoreCart } from '@woocommerce/base-hooks';
|
||||
import {
|
||||
useEmitResponse,
|
||||
usePaymentMethods,
|
||||
useStoreCart,
|
||||
} from '@woocommerce/base-hooks';
|
||||
import { PaymentMethods } from '@woocommerce/base-components/payment-methods';
|
||||
|
||||
const PaymentMethodStep = () => {
|
||||
const { isProcessing: checkoutIsProcessing } = useCheckoutContext();
|
||||
const { cartNeedsPayment } = useStoreCart();
|
||||
const { paymentMethods } = usePaymentMethods();
|
||||
const { noticeContexts } = useEmitResponse();
|
||||
|
||||
if ( ! cartNeedsPayment ) {
|
||||
return null;
|
||||
|
@ -34,7 +39,7 @@ const PaymentMethodStep = () => {
|
|||
: ''
|
||||
}
|
||||
>
|
||||
<StoreNoticesProvider context="wc/payment-area">
|
||||
<StoreNoticesProvider context={ noticeContexts.PAYMENTS }>
|
||||
<PaymentMethods />
|
||||
</StoreNoticesProvider>
|
||||
</FormStep>
|
||||
|
|
Loading…
Reference in New Issue