Cart: Accepted Payment Methods block: Use utility instead of the local function (https://github.com/woocommerce/woocommerce-blocks/pull/6001)
This commit is contained in:
parent
2e674dd6c0
commit
22cdefd3da
|
@ -9,8 +9,6 @@ import type {
|
|||
/**
|
||||
* Get the provider icons from payment methods data.
|
||||
*
|
||||
* @todo Refactor the Cart blocks to use getIconsFromPaymentMethods utility instead of the local copy.
|
||||
*
|
||||
* @param {PaymentMethods} paymentMethods Payment Method data
|
||||
* @return {PaymentMethodIconsType} Payment Method icons data.
|
||||
*/
|
||||
|
|
|
@ -3,21 +3,7 @@
|
|||
*/
|
||||
import { PaymentMethodIcons } from '@woocommerce/base-components/cart-checkout';
|
||||
import { usePaymentMethods } from '@woocommerce/base-context/hooks';
|
||||
import type {
|
||||
PaymentMethods,
|
||||
PaymentMethodIcons as PaymentMethodIconsType,
|
||||
} from '@woocommerce/type-defs/payments';
|
||||
|
||||
const getIconsFromPaymentMethods = (
|
||||
paymentMethods: PaymentMethods
|
||||
): PaymentMethodIconsType => {
|
||||
return Object.values( paymentMethods ).reduce( ( acc, paymentMethod ) => {
|
||||
if ( paymentMethod.icons !== null ) {
|
||||
acc = acc.concat( paymentMethod.icons );
|
||||
}
|
||||
return acc;
|
||||
}, [] as PaymentMethodIconsType );
|
||||
};
|
||||
import { getIconsFromPaymentMethods } from '@woocommerce/base-utils';
|
||||
|
||||
const Block = ( { className }: { className: string } ): JSX.Element => {
|
||||
const { paymentMethods } = usePaymentMethods();
|
||||
|
|
Loading…
Reference in New Issue