/** * Create Modal popup. * Edit: Use React Hook. * * @author Nhamdv - ThimPress. */ import store from './store'; import { __ } from '@wordpress/i18n'; import { useSelect, dispatch } from '@wordpress/data'; const Modal = ( { children } ) => { const { show, hide, confirm } = dispatch( 'learnpress/modal' ); const isShow = useSelect( ( select ) => { const isOpen = select( 'learnpress/modal' ).isOpen(); return isOpen; } ); const message = useSelect( ( select ) => { const getMessage = select( 'learnpress/modal' ).getMessage(); return getMessage; } ); const dataConfirm = ( c ) => ( event ) => { confirm( c ); }; const styles = { display: isShow ? 'block' : 'none', }; return ( <>
{ children } ); }; export default Modal;