diff --git a/assets/js/base/context/providers/cart-checkout/checkout-processor.js b/assets/js/base/context/providers/cart-checkout/checkout-processor.js index 3f9d4caf6b4..183d1721569 100644 --- a/assets/js/base/context/providers/cart-checkout/checkout-processor.js +++ b/assets/js/base/context/providers/cart-checkout/checkout-processor.js @@ -55,7 +55,7 @@ const CheckoutProcessor = () => { }; } ); - const { setCustomerId, setHasError, processCheckoutResponse } = useDispatch( + const { setHasError, processCheckoutResponse } = useDispatch( CHECKOUT_STORE_KEY ); @@ -226,10 +226,7 @@ const CheckoutProcessor = () => { parse: false, } ) .then( ( response ) => { - processCheckoutResponseHeaders( - response.headers, - setCustomerId - ); + processCheckoutResponseHeaders( response.headers ); if ( ! response.ok ) { throw new Error( response ); } @@ -242,10 +239,7 @@ const CheckoutProcessor = () => { .catch( ( errorResponse ) => { try { if ( errorResponse?.headers ) { - processCheckoutResponseHeaders( - errorResponse.headers, - setCustomerId - ); + processCheckoutResponseHeaders( errorResponse.headers ); } // This attempts to parse a JSON error response where the status code was 4xx/5xx. errorResponse.json().then( ( response ) => { @@ -309,7 +303,6 @@ const CheckoutProcessor = () => { receiveCart, setHasError, processCheckoutResponse, - setCustomerId, ] ); // Process order if conditions are good. diff --git a/assets/js/base/context/providers/cart-checkout/utils.ts b/assets/js/base/context/providers/cart-checkout/utils.ts index 8e636f5b3e8..1e1d16a9806 100644 --- a/assets/js/base/context/providers/cart-checkout/utils.ts +++ b/assets/js/base/context/providers/cart-checkout/utils.ts @@ -2,11 +2,8 @@ * External dependencies */ import triggerFetch from '@wordpress/api-fetch'; - -/** - * Internal dependencies - */ -import type { setCustomerId as setCheckoutCustomerId } from '../../../../data/checkout/actions'; +import { dispatch } from '@wordpress/data'; +import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data'; /** * Utility function for preparing payment data for the request. @@ -34,10 +31,8 @@ export const preparePaymentData = ( /** * Process headers from an API response an dispatch updates. */ -export const processCheckoutResponseHeaders = ( - headers: Headers, - setCustomerId: typeof setCheckoutCustomerId -): void => { +export const processCheckoutResponseHeaders = ( headers: Headers ): void => { + const { setCustomerId } = dispatch( CHECKOUT_STORE_KEY ); if ( // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore -- this does exist because it's monkey patched in