woocommerce/plugins/woocommerce-blocks/assets/js/editor-components/incompatible-extension-notice/use-incompatible-payment-ga...

36 lines
819 B
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import { STORE_KEY as PAYMENT_STORE_KEY } from '../../data/payment/constants';
export const useIncompatiblePaymentGatewaysNotice = (): [
{ [ k: string ]: string },
string[],
number
] => {
const { incompatiblePaymentMethods } = useSelect( ( select ) => {
const { getIncompatiblePaymentMethods } = select( PAYMENT_STORE_KEY );
return {
incompatiblePaymentMethods: getIncompatiblePaymentMethods(),
};
}, [] );
const incompatiblePaymentMethodSlugs = Object.keys(
incompatiblePaymentMethods
);
const incompatiblePaymentMethodCount =
incompatiblePaymentMethodSlugs.length;
return [
incompatiblePaymentMethods,
incompatiblePaymentMethodSlugs,
incompatiblePaymentMethodCount,
];
};