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:
Tung Du 2022-03-09 07:06:32 +07:00 committed by GitHub
parent 2e674dd6c0
commit 22cdefd3da
2 changed files with 1 additions and 17 deletions

View File

@ -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.
*/

View File

@ -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();