2020-04-29 10:57:58 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2021-06-29 14:04:24 +00:00
|
|
|
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
2021-09-15 16:36:02 +00:00
|
|
|
import type { PaymentMethodIcon } from '@woocommerce/type-defs/payments';
|
2020-04-29 10:57:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of common assets.
|
|
|
|
*/
|
2021-08-20 11:55:30 +00:00
|
|
|
export const commonIcons: PaymentMethodIcon[] = [
|
2020-04-29 10:57:58 +00:00
|
|
|
{
|
|
|
|
id: 'alipay',
|
|
|
|
alt: 'Alipay',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/alipay.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'amex',
|
|
|
|
alt: 'American Express',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/amex.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'bancontact',
|
|
|
|
alt: 'Bancontact',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/bancontact.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'diners',
|
|
|
|
alt: 'Diners Club',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/diners.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'discover',
|
|
|
|
alt: 'Discover',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/discover.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'eps',
|
|
|
|
alt: 'EPS',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/eps.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'giropay',
|
|
|
|
alt: 'Giropay',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/giropay.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'ideal',
|
|
|
|
alt: 'iDeal',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/ideal.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'jcb',
|
|
|
|
alt: 'JCB',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/jcb.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'laser',
|
|
|
|
alt: 'Laser',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/laser.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'maestro',
|
|
|
|
alt: 'Maestro',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/maestro.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'mastercard',
|
|
|
|
alt: 'Mastercard',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/mastercard.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'multibanco',
|
|
|
|
alt: 'Multibanco',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/multibanco.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'p24',
|
|
|
|
alt: 'Przelewy24',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/p24.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'sepa',
|
|
|
|
alt: 'Sepa',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/sepa.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'sofort',
|
|
|
|
alt: 'Sofort',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/sofort.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'unionpay',
|
|
|
|
alt: 'Union Pay',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/unionpay.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'visa',
|
|
|
|
alt: 'Visa',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/visa.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'wechat',
|
|
|
|
alt: 'WeChat',
|
2021-06-29 14:04:24 +00:00
|
|
|
src: WC_BLOCKS_IMAGE_URL + 'payment-methods/wechat.svg',
|
2020-04-29 10:57:58 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For a given ID, see if a common icon exists and return it's props.
|
|
|
|
*
|
|
|
|
* @param {string} id Icon ID.
|
|
|
|
*/
|
2021-08-20 11:55:30 +00:00
|
|
|
export const getCommonIconProps = (
|
|
|
|
id: string
|
|
|
|
): PaymentMethodIcon | Record< string, unknown > => {
|
2020-04-29 10:57:58 +00:00
|
|
|
return (
|
|
|
|
commonIcons.find( ( icon ) => {
|
|
|
|
return icon.id === id;
|
|
|
|
} ) || {}
|
|
|
|
);
|
|
|
|
};
|