woocommerce/plugins/woocommerce-admin/client/marketing/overview-multichannel/DiscoverTools/useRecommendedPlugins.ts

32 lines
633 B
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import { STORE_KEY } from '~/marketing/data/constants';
import { Plugin } from './types';
const category = 'marketing';
type SelectResult = {
isLoading: boolean;
plugins: Plugin[];
};
export const useRecommendedPlugins = () => {
return useSelect< SelectResult >(
( select ) => {
const { getRecommendedPlugins, isResolving } = select( STORE_KEY );
return {
isLoading: isResolving( 'getRecommendedPlugins', [ category ] ),
plugins: getRecommendedPlugins( category ),
};
},
[ category ]
);
};