File size: 555 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { useDispatch } from '@wordpress/data';
import { HELP_CENTER_STORE } from '../stores';

export const useOpenArticleInHelpCenter = () => {
	const helpCenterDispatch = useDispatch( HELP_CENTER_STORE );
	const setShowSupportDoc = helpCenterDispatch?.setShowSupportDoc;

	const openArticleInHelpCenter = ( articleLink: string ) => {
		if ( setShowSupportDoc ) {
			setShowSupportDoc( articleLink );
		} else {
			// eslint-disable-next-line no-console
			console.warn( 'Help Center is not available' );
		}
	};

	return { openArticleInHelpCenter };
};