2023-10-04 12:24:51 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { Button } from '@wordpress/components';
|
2023-10-09 05:19:08 +00:00
|
|
|
import { getNewPath } from '@woocommerce/navigation';
|
2023-10-04 12:24:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { Intro } from '.';
|
2023-10-31 16:11:26 +00:00
|
|
|
import { IntroSiteIframe } from './intro-site-iframe';
|
|
|
|
import { getAdminSetting } from '~/utils/admin-settings';
|
2023-10-26 08:46:50 +00:00
|
|
|
import { navigateOrParent } from '../utils';
|
2023-10-04 12:24:51 +00:00
|
|
|
|
|
|
|
export const BaseIntroBanner = ( {
|
|
|
|
bannerTitle,
|
|
|
|
bannerText,
|
|
|
|
bannerClass,
|
|
|
|
buttonIsLink,
|
|
|
|
bannerButtonOnClick,
|
|
|
|
bannerButtonText,
|
2023-10-31 16:11:26 +00:00
|
|
|
secondaryButton,
|
2023-10-09 05:19:08 +00:00
|
|
|
children,
|
2023-10-04 12:24:51 +00:00
|
|
|
}: {
|
|
|
|
bannerTitle: string;
|
|
|
|
bannerText: string;
|
|
|
|
bannerClass: string;
|
2023-10-12 02:49:25 +00:00
|
|
|
buttonIsLink?: boolean;
|
|
|
|
bannerButtonOnClick?: () => void;
|
|
|
|
bannerButtonText?: string;
|
2023-10-31 16:11:26 +00:00
|
|
|
secondaryButton?: React.ReactNode;
|
2023-10-09 05:19:08 +00:00
|
|
|
children?: React.ReactNode;
|
2023-10-04 12:24:51 +00:00
|
|
|
} ) => {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={ classNames(
|
|
|
|
'woocommerce-customize-store-banner',
|
|
|
|
bannerClass
|
|
|
|
) }
|
|
|
|
>
|
|
|
|
<div className={ `woocommerce-customize-store-banner-content` }>
|
2023-10-31 16:11:26 +00:00
|
|
|
<div className="banner-actions">
|
|
|
|
<h1>{ bannerTitle }</h1>
|
|
|
|
<p>{ bannerText }</p>
|
|
|
|
{ bannerButtonText && (
|
|
|
|
<Button
|
|
|
|
onClick={ () =>
|
|
|
|
bannerButtonOnClick && bannerButtonOnClick()
|
|
|
|
}
|
|
|
|
variant={ buttonIsLink ? 'link' : 'primary' }
|
|
|
|
>
|
|
|
|
{ bannerButtonText }
|
|
|
|
</Button>
|
|
|
|
) }
|
|
|
|
{ secondaryButton }
|
|
|
|
</div>
|
2023-10-09 05:19:08 +00:00
|
|
|
{ children }
|
2023-10-04 12:24:51 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const NetworkOfflineBanner = () => {
|
|
|
|
return (
|
|
|
|
<BaseIntroBanner
|
|
|
|
bannerTitle={ __(
|
|
|
|
'Looking to design your store using AI?',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerText={ __(
|
2023-10-12 02:49:25 +00:00
|
|
|
"Unfortunately, the [AI Store designer] isn't available right now as we can't detect your network. Please check your internet connection.",
|
2023-10-04 12:24:51 +00:00
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerClass="offline-banner"
|
|
|
|
bannerButtonOnClick={ () => {} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const JetpackOfflineBanner = ( {
|
|
|
|
sendEvent,
|
|
|
|
}: {
|
|
|
|
sendEvent: React.ComponentProps< typeof Intro >[ 'sendEvent' ];
|
|
|
|
} ) => {
|
|
|
|
return (
|
|
|
|
<BaseIntroBanner
|
|
|
|
bannerTitle={ __(
|
|
|
|
'Looking to design your store using AI?',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerText={ __(
|
|
|
|
"It looks like you're using Jetpack's offline mode — switch to online mode to start designing with AI.",
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerClass="offline-banner"
|
|
|
|
buttonIsLink={ false }
|
|
|
|
bannerButtonOnClick={ () => {
|
|
|
|
sendEvent( {
|
|
|
|
type: 'JETPACK_OFFLINE_HOWTO',
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
bannerButtonText={ __( 'Find out how', 'woocommerce' ) }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-10-09 05:19:08 +00:00
|
|
|
export const ExistingThemeBanner = ( {
|
|
|
|
setOpenDesignChangeWarningModal,
|
|
|
|
}: {
|
|
|
|
setOpenDesignChangeWarningModal: ( arg0: boolean ) => void;
|
|
|
|
} ) => {
|
|
|
|
return (
|
|
|
|
<BaseIntroBanner
|
|
|
|
bannerTitle={ __(
|
|
|
|
'Use the power of AI to design your store',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerText={ __(
|
|
|
|
'Design the look of your store, create pages, and generate copy using our built-in AI tools.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerClass=""
|
|
|
|
buttonIsLink={ false }
|
|
|
|
bannerButtonOnClick={ () => {
|
|
|
|
setOpenDesignChangeWarningModal( true );
|
|
|
|
} }
|
|
|
|
bannerButtonText={ __( 'Design with AI', 'woocommerce' ) }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-10-04 12:24:51 +00:00
|
|
|
export const DefaultBanner = ( {
|
|
|
|
sendEvent,
|
|
|
|
}: {
|
|
|
|
sendEvent: React.ComponentProps< typeof Intro >[ 'sendEvent' ];
|
|
|
|
} ) => {
|
|
|
|
return (
|
|
|
|
<BaseIntroBanner
|
|
|
|
bannerTitle={ __(
|
|
|
|
'Use the power of AI to design your store',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerText={ __(
|
|
|
|
'Design the look of your store, create pages, and generate copy using our built-in AI tools.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerClass=""
|
|
|
|
buttonIsLink={ false }
|
|
|
|
bannerButtonOnClick={ () => {
|
|
|
|
sendEvent( {
|
|
|
|
type: 'DESIGN_WITH_AI',
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
bannerButtonText={ __( 'Design with AI', 'woocommerce' ) }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ThemeHasModsBanner = ( {
|
|
|
|
setOpenDesignChangeWarningModal,
|
|
|
|
}: {
|
|
|
|
setOpenDesignChangeWarningModal: ( arg0: boolean ) => void;
|
|
|
|
} ) => {
|
|
|
|
return (
|
|
|
|
<BaseIntroBanner
|
|
|
|
bannerTitle={ __(
|
|
|
|
'Use the power of AI to design your store',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerText={ __(
|
|
|
|
'Design the look of your store, create pages, and generate copy using our built-in AI tools.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerClass=""
|
|
|
|
buttonIsLink={ false }
|
|
|
|
bannerButtonOnClick={ () => {
|
|
|
|
setOpenDesignChangeWarningModal( true );
|
|
|
|
} }
|
|
|
|
bannerButtonText={ __( 'Design with AI', 'woocommerce' ) }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2023-10-09 05:19:08 +00:00
|
|
|
|
|
|
|
export const ExistingAiThemeBanner = ( {
|
|
|
|
setOpenDesignChangeWarningModal,
|
|
|
|
}: {
|
|
|
|
setOpenDesignChangeWarningModal: ( arg0: boolean ) => void;
|
|
|
|
} ) => {
|
2023-10-31 16:11:26 +00:00
|
|
|
const secondaryButton = (
|
|
|
|
<Button
|
|
|
|
className=""
|
|
|
|
onClick={ () => {
|
|
|
|
setOpenDesignChangeWarningModal( true );
|
|
|
|
} }
|
|
|
|
variant={ 'secondary' }
|
|
|
|
>
|
|
|
|
{ __( 'Create a new one', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1';
|
|
|
|
|
2023-10-09 05:19:08 +00:00
|
|
|
return (
|
|
|
|
<BaseIntroBanner
|
|
|
|
bannerTitle={ __( 'Customize your custom theme', 'woocommerce' ) }
|
|
|
|
bannerText={ __(
|
|
|
|
'Keep customizing the look of your AI-generated store, or start over and create a new one.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
bannerClass="existing-ai-theme-banner"
|
|
|
|
buttonIsLink={ false }
|
|
|
|
bannerButtonOnClick={ () => {
|
2023-10-26 08:46:50 +00:00
|
|
|
navigateOrParent(
|
|
|
|
window,
|
|
|
|
getNewPath( {}, '/customize-store/assembler-hub', {} )
|
2023-10-09 05:19:08 +00:00
|
|
|
);
|
|
|
|
} }
|
|
|
|
bannerButtonText={ __( 'Customize', 'woocommerce' ) }
|
2023-10-31 16:11:26 +00:00
|
|
|
secondaryButton={ secondaryButton }
|
2023-10-09 05:19:08 +00:00
|
|
|
>
|
2023-10-31 16:11:26 +00:00
|
|
|
<div className={ 'woocommerce-block-preview-container' }>
|
|
|
|
<div className="iframe-container">
|
|
|
|
<IntroSiteIframe siteUrl={ siteUrl } />
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-10-09 05:19:08 +00:00
|
|
|
</BaseIntroBanner>
|
|
|
|
);
|
|
|
|
};
|