| 1 |
import { Dialog } from '@elementor/app-ui'; |
| 2 |
import { useSettingsContext } from '../context/settings-context'; |
| 3 |
|
| 4 |
const { useEffect, useRef } = React; |
| 5 |
|
| 6 |
export default function ConnectDialog( props ) { |
| 7 |
const { settings } = useSettingsContext(); |
| 8 |
const approveButtonRef = useRef(); |
| 9 |
|
| 10 |
useEffect( () => { |
| 11 |
jQuery( approveButtonRef.current ).elementorConnect( { |
| 12 |
success: ( e, data ) => props.onSuccess( data ), |
| 13 |
error: () => props.onError( __( 'Unable to connect', 'elementor' ) ), |
| 14 |
parseUrl: ( url ) => url.replace( '%%page%%', props.pageId ), |
| 15 |
} ); |
| 16 |
}, [] ); |
| 17 |
|
| 18 |
return ( |
| 19 |
<Dialog |
| 20 |
title={ __( 'Connect to Template Library', 'elementor' ) } |
| 21 |
text={ __( 'Access this template and our entire library by creating a free personal account', 'elementor' ) } |
| 22 |
approveButtonText={ __( 'Get Started', 'elementor' ) } |
| 23 |
approveButtonUrl={ settings.library_connect_url } |
| 24 |
approveButtonOnClick={ () => props.onClose() } |
| 25 |
approveButtonColor="primary" |
| 26 |
approveButtonRef={ approveButtonRef } |
| 27 |
dismissButtonText={ __( 'Cancel', 'elementor-pro' ) } |
| 28 |
dismissButtonOnClick={ () => props.onClose() } |
| 29 |
onClose={ () => props.onClose() } |
| 30 |
/> |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
ConnectDialog.propTypes = { |
| 35 |
onClose: PropTypes.func.isRequired, |
| 36 |
onError: PropTypes.func.isRequired, |
| 37 |
onSuccess: PropTypes.func.isRequired, |
| 38 |
pageId: PropTypes.string, |
| 39 |
}; |
| 40 |
|