woocommerce/plugins/woocommerce-admin/client/marketing/components/PluginCardBody/useIsPluginInstalledNotActi...

25 lines
625 B
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { useCallback } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
export const useIsPluginInstalledNotActivated = () => {
const { getPluginInstallState } = useSelect( ( select ) => {
return {
getPluginInstallState:
select( PLUGINS_STORE_NAME ).getPluginInstallState,
};
} );
const isPluginInstalledNotActivated = useCallback(
( slug: string ) => {
return getPluginInstallState( slug ) === 'installed';
},
[ getPluginInstallState ]
);
return { isPluginInstalledNotActivated };
};