PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0
Elementor Website Builder – more than just a page builder v3.8.0
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / app / modules / onboarding / assets / js / utils / connect.js

connect.js in Elementor Website Builder – more than just a page builder 3.8.0, at app/modules/onboarding/assets/js/utils/connect.js

41 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect, useContext } from 'react';
2 import { OnboardingContext } from '../context/context';
3
4 export default function Connect( props ) {
5 const { state, updateState, getStateObjectToUpdate } = useContext( OnboardingContext );
6
7 const connectSuccessCallback = ( data ) => {
8 const stateToUpdate = getStateObjectToUpdate( state, 'steps', 'account', 'completed' );
9
10 elementorCommon.config.library_connect.is_connected = true;
11 elementorCommon.config.library_connect.current_access_level = data.kits_access_level || data.access_level || 0;
12
13 stateToUpdate.isLibraryConnected = true;
14
15 updateState( stateToUpdate );
16 };
17
18 useEffect( () => {
19 jQuery( props.buttonRef.current ).elementorConnect( {
20 success: ( data ) => props.successCallback ? props.successCallback( data ) : connectSuccessCallback( data ),
21 error: () => {
22 if ( props.errorCallback ) {
23 props.errorCallback();
24 }
25 },
26 popup: {
27 width: 726,
28 height: 534,
29 },
30 } );
31 }, [] );
32
33 return null;
34 }
35
36 Connect.propTypes = {
37 buttonRef: PropTypes.object.isRequired,
38 successCallback: PropTypes.func,
39 errorCallback: PropTypes.func,
40 };
41