| Server IP : 3.93.235.159 / Your IP : 216.73.216.140 Web Server : Apache System : Linux ip-172-26-0-169 5.10.0-46-cloud-amd64 #1 SMP Debian 5.10.262-1 (2026-07-31) x86_64 User : bitnami ( 1000) PHP Version : 8.2.9 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/hello-plus/modules/admin/assets/js/pages/ |
Upload File : |
import Box from '@elementor/ui/Box';
import { ThemeProvider } from '@elementor/ui/styles';
import { __ } from '@wordpress/i18n';
import { useCallback, useState } from 'react';
import { useAdminContext } from '../hooks/use-admin-context';
import Modal from '@elementor/ui/Modal';
import Button from '@elementor/ui/Button';
import { TopBarContent } from '../components/top-bar/top-bar-content';
import { GetStarted } from '../components/onboarding/screens/get-started';
import Spinner from '../components/spinner/spinner';
import { InstallKit } from '../components/onboarding/screens/install-kit';
import { ReadyToGo } from '../components/onboarding/screens/ready-to-go';
import { Preview } from '../components/onboarding/screens/preview';
export const OnboardingPage = () => {
const [ message, setMessage ] = useState( '' );
const [ severity, setSeverity ] = useState( 'info' );
const [ previewKit, setPreviewKit ] = useState( null );
const {
isLoading,
setIsLoading,
stepAction,
step,
onboardingSettings: { nonce, modalCloseRedirectUrl, kits, getStartedText = {}, readyToGoText = {}, installKitText = {} } = {},
isBlankKit,
setIsBlankKit,
} = useAdminContext();
const {
title = '',
description = '',
disclaimer = '',
termsUrl = '',
termsText = '',
buttonText: getStartedButtonText = '',
} = getStartedText;
const {
title: readyTitle = '',
description: readyDescription = '',
viewSite = '',
customizeSite = '',
titleBlank = '',
descriptionBlank = '',
viewSiteBlank = '',
customizeSiteBlank = '',
} = readyToGoText;
const {
title: kitTitle = '',
description: kitDescription = '',
} = installKitText;
const onClick = useCallback( async () => {
setMessage( '' );
const data = {
step: stepAction,
_wpnonce: nonce,
slug: 'elementor',
};
setIsLoading( true );
try {
switch ( stepAction ) {
case 'install-elementor':
const response = await wp.ajax.post( 'helloplus_setup_wizard', data );
if ( response.activateUrl ) {
const activate = await fetch( response.activateUrl );
if ( activate.ok ) {
window.location.reload();
} else {
throw new Error( __( 'Failed to activate Elementor plugin', 'hello-plus' ) );
}
}
break;
case 'activate-elementor':
await wp.ajax.post( 'helloplus_setup_wizard', data );
window.location.reload();
break;
default:
break;
}
} catch ( error ) {
setMessage( error.errorMessage );
setSeverity( 'error' );
} finally {
setIsLoading( false );
}
}, [ nonce, setIsLoading, stepAction ] );
const onClose = () => {
window.location.href = modalCloseRedirectUrl;
};
const blankCanvasButton = 1 === step ? (
<Button
variant="outlined"
color="secondary"
onClick={ () => setIsBlankKit( true ) }
>
{ __( 'Build with blank canvas', 'hello-plus' ) }
</Button>
) : null;
return (
<ThemeProvider colorScheme="auto">
<Modal open sx={ { zIndex: 100000 } } >
<Box sx={ {
backgroundColor: 'background.default',
position: 'fixed',
top: 0,
left: 0,
width: '100%',
height: '100%',
boxShadow: 24,
display: 'flex',
flexDirection: 'column',
} }>
{ ! previewKit && ( <TopBarContent onClose={ onClose } actionButton={ blankCanvasButton } sx={ { borderBottom: '1px solid var(--divider-divider, rgba(0, 0, 0, 0.12))', mb: 4 } } iconSize="small" /> ) }
{ 0 === step && ! isLoading && ! previewKit && (
<GetStarted
severity={ severity }
message={ message }
buttonText={ getStartedButtonText }
onClick={ onClick }
title={ title }
description={ description }
disclaimer={ disclaimer }
termsUrl={ termsUrl }
termsText={ termsText }
/>
) }
{ 1 === step && ! isLoading && ! previewKit && (
<InstallKit
setPreviewKit={ setPreviewKit }
severity={ severity }
message={ message }
kits={ kits }
title={ kitTitle }
description={ kitDescription }
/>
) }
{ 2 === step && ! isLoading && ! previewKit && (
<ReadyToGo
modalCloseRedirectUrl={ modalCloseRedirectUrl }
title={ isBlankKit ? titleBlank : readyTitle }
description={ isBlankKit ? descriptionBlank : readyDescription }
viewSite={ isBlankKit ? viewSiteBlank : viewSite }
customizeSite={ isBlankKit ? customizeSiteBlank : customizeSite }
/>
) }
{ previewKit && <Preview kit={ previewKit } setPreviewKit={ setPreviewKit } /> }
{ isLoading && <Spinner /> }
</Box>
</Modal>
</ThemeProvider>
);
};