2023-10-05 12:36:08 +00:00
|
|
|
/* eslint-disable @woocommerce/dependency-group */
|
|
|
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
2023-11-07 09:34:20 +00:00
|
|
|
|
2023-09-15 04:01:02 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2023-10-05 12:36:08 +00:00
|
|
|
import classNames from 'classnames';
|
2023-09-15 04:01:02 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { getSetting } from '@woocommerce/settings';
|
2023-09-18 11:01:12 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2023-09-15 04:01:02 +00:00
|
|
|
import {
|
|
|
|
Button,
|
2023-11-07 09:34:20 +00:00
|
|
|
Modal,
|
2023-09-15 04:01:02 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// @ts-ignore No types for this exist yet.
|
|
|
|
__unstableMotion as motion,
|
|
|
|
} from '@wordpress/components';
|
2023-10-05 12:36:08 +00:00
|
|
|
// @ts-ignore No types for this exist yet.
|
|
|
|
import { useIsSiteEditorLoading } from '@wordpress/edit-site/build-module/components/layout/hooks';
|
2023-09-15 04:01:02 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { SiteHub } from '../assembler-hub/site-hub';
|
|
|
|
import { ADMIN_URL } from '~/utils/admin-settings';
|
2023-10-05 12:36:08 +00:00
|
|
|
|
2023-09-15 04:01:02 +00:00
|
|
|
import './style.scss';
|
2023-10-26 08:46:50 +00:00
|
|
|
import { navigateOrParent } from '../utils';
|
2023-11-01 11:40:12 +00:00
|
|
|
import { WooCYSSecondaryButtonSlot } from './secondary-button-slot';
|
2023-11-07 09:34:20 +00:00
|
|
|
import { SurveyForm } from './survey-form';
|
2023-09-15 04:01:02 +00:00
|
|
|
|
2023-11-10 08:35:46 +00:00
|
|
|
export * as actions from './actions';
|
|
|
|
export * as services from './services';
|
|
|
|
|
|
|
|
export type events = { type: 'GO_BACK_TO_HOME' } | { type: 'COMPLETE_SURVEY' };
|
2023-09-15 04:01:02 +00:00
|
|
|
|
|
|
|
export const Transitional = ( {
|
2023-10-05 12:36:08 +00:00
|
|
|
editor,
|
2023-09-15 04:01:02 +00:00
|
|
|
sendEvent,
|
2023-11-10 08:35:46 +00:00
|
|
|
hasCompleteSurvey,
|
2023-11-07 09:34:20 +00:00
|
|
|
isSurveyOpen,
|
|
|
|
setSurveyOpen,
|
2023-11-29 14:00:40 +00:00
|
|
|
aiOnline,
|
2023-09-15 04:01:02 +00:00
|
|
|
}: {
|
2023-10-05 12:36:08 +00:00
|
|
|
editor: React.ReactNode;
|
2023-09-15 04:01:02 +00:00
|
|
|
sendEvent: ( event: events ) => void;
|
2023-11-10 08:35:46 +00:00
|
|
|
hasCompleteSurvey: boolean;
|
2023-11-07 09:34:20 +00:00
|
|
|
isSurveyOpen: boolean;
|
|
|
|
setSurveyOpen: ( isOpen: boolean ) => void;
|
2023-11-29 14:00:40 +00:00
|
|
|
aiOnline: boolean;
|
2023-09-15 04:01:02 +00:00
|
|
|
} ) => {
|
|
|
|
const homeUrl: string = getSetting( 'homeUrl', '' );
|
2023-10-05 12:36:08 +00:00
|
|
|
const isEditorLoading = useIsSiteEditorLoading();
|
2023-11-07 09:34:20 +00:00
|
|
|
const closeSurvey = () => {
|
|
|
|
setSurveyOpen( false );
|
|
|
|
};
|
|
|
|
|
2023-09-15 04:01:02 +00:00
|
|
|
return (
|
|
|
|
<div className="woocommerce-customize-store__transitional">
|
2023-11-29 14:00:40 +00:00
|
|
|
{ isSurveyOpen && aiOnline && (
|
2023-11-07 09:34:20 +00:00
|
|
|
<Modal
|
|
|
|
title={ __( 'Share feedback', 'woocommerce' ) }
|
|
|
|
onRequestClose={ () => closeSurvey() }
|
|
|
|
shouldCloseOnClickOutside={ false }
|
|
|
|
className="woocommerce-ai-survey-modal"
|
|
|
|
>
|
2023-11-10 08:35:46 +00:00
|
|
|
<SurveyForm
|
|
|
|
onSend={ () => {
|
|
|
|
sendEvent( {
|
|
|
|
type: 'COMPLETE_SURVEY',
|
|
|
|
} );
|
|
|
|
closeSurvey();
|
|
|
|
} }
|
|
|
|
closeFunction={ closeSurvey }
|
|
|
|
/>
|
2023-11-07 09:34:20 +00:00
|
|
|
</Modal>
|
|
|
|
) }
|
2023-09-15 04:01:02 +00:00
|
|
|
<SiteHub
|
|
|
|
as={ motion.div }
|
|
|
|
variants={ {
|
|
|
|
view: { x: 0 },
|
|
|
|
} }
|
|
|
|
isTransparent={ false }
|
|
|
|
className="edit-site-layout__hub"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div className="woocommerce-customize-store__transitional-content">
|
|
|
|
<h1 className="woocommerce-customize-store__transitional-heading">
|
|
|
|
{ __( 'Your store looks great!', 'woocommerce' ) }
|
|
|
|
</h1>
|
|
|
|
<h2 className="woocommerce-customize-store__transitional-subheading">
|
|
|
|
{ __(
|
2023-11-07 01:28:56 +00:00
|
|
|
"You're one step closer to launching your online business — we can't wait to see it come to life.",
|
2023-09-15 04:01:02 +00:00
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</h2>
|
2023-11-01 11:40:12 +00:00
|
|
|
|
|
|
|
<div className="woocommerce-customize-store__transitional-main-actions">
|
|
|
|
<WooCYSSecondaryButtonSlot />
|
|
|
|
|
2023-11-29 14:00:40 +00:00
|
|
|
{ ! hasCompleteSurvey && aiOnline && (
|
2023-11-10 08:35:46 +00:00
|
|
|
<Button
|
|
|
|
className="woocommerce-customize-store__transitional-preview-button"
|
|
|
|
variant="secondary"
|
|
|
|
onClick={ () => {
|
|
|
|
recordEvent(
|
|
|
|
'customize_your_store_transitional_survey_click'
|
|
|
|
);
|
|
|
|
setSurveyOpen( true );
|
|
|
|
} }
|
|
|
|
>
|
|
|
|
{ __( 'Share feedback', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
2023-11-07 09:34:20 +00:00
|
|
|
|
2023-11-01 11:40:12 +00:00
|
|
|
<Button
|
|
|
|
className="woocommerce-customize-store__transitional-preview-button"
|
|
|
|
variant="primary"
|
|
|
|
onClick={ () => {
|
|
|
|
recordEvent(
|
|
|
|
'customize_your_store_transitional_preview_store_click'
|
|
|
|
);
|
|
|
|
window.open( homeUrl, '_blank' );
|
|
|
|
} }
|
|
|
|
>
|
|
|
|
{ __( 'Preview store', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
</div>
|
2023-09-15 04:01:02 +00:00
|
|
|
|
2023-10-05 12:36:08 +00:00
|
|
|
<div
|
|
|
|
className={ classNames(
|
|
|
|
'woocommerce-customize-store__transitional-site-preview-container',
|
|
|
|
{
|
|
|
|
'is-loading': isEditorLoading,
|
|
|
|
}
|
|
|
|
) }
|
|
|
|
>
|
|
|
|
{ editor }
|
2023-09-15 04:01:02 +00:00
|
|
|
</div>
|
|
|
|
<div className="woocommerce-customize-store__transitional-actions">
|
|
|
|
<div className="woocommerce-customize-store__transitional-action">
|
|
|
|
<h3>
|
|
|
|
{ __( 'Fine-tune your design', 'woocommerce' ) }
|
|
|
|
</h3>
|
|
|
|
<p>
|
|
|
|
{ __(
|
|
|
|
'Head to the Editor to change your images and text, add more pages, and make any further customizations.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</p>
|
|
|
|
<Button
|
|
|
|
variant="tertiary"
|
2023-09-18 11:01:12 +00:00
|
|
|
onClick={ () => {
|
|
|
|
recordEvent(
|
|
|
|
'customize_your_store_transitional_editor_click'
|
|
|
|
);
|
2023-10-26 08:46:50 +00:00
|
|
|
navigateOrParent(
|
|
|
|
window,
|
|
|
|
`${ ADMIN_URL }site-editor.php`
|
|
|
|
);
|
2023-09-18 11:01:12 +00:00
|
|
|
} }
|
2023-09-15 04:01:02 +00:00
|
|
|
>
|
|
|
|
{ __( 'Go to the Editor', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="woocommerce-customize-store__transitional-action">
|
|
|
|
<h3>
|
|
|
|
{ __(
|
|
|
|
'Continue setting up your store',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</h3>
|
|
|
|
<p>
|
|
|
|
{ __(
|
|
|
|
'Go back to the Home screen to complete your store setup and start selling',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</p>
|
|
|
|
<Button
|
|
|
|
variant="tertiary"
|
2023-09-18 11:01:12 +00:00
|
|
|
onClick={ () => {
|
|
|
|
recordEvent(
|
|
|
|
'customize_your_store_transitional_home_click'
|
|
|
|
);
|
2023-09-15 04:01:02 +00:00
|
|
|
sendEvent( {
|
|
|
|
type: 'GO_BACK_TO_HOME',
|
2023-09-18 11:01:12 +00:00
|
|
|
} );
|
|
|
|
} }
|
2023-09-15 04:01:02 +00:00
|
|
|
>
|
|
|
|
{ __( 'Back to Home', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|