/** * External dependencies */ import { __ } from '@wordpress/i18n'; import clsx from 'clsx'; import { Button } from '@wordpress/components'; import { getNewPath } from '@woocommerce/navigation'; import interpolateComponents from '@automattic/interpolate-components'; import { Link } from '@woocommerce/components'; import { useState } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; /** * Internal dependencies */ import { Intro } from '.'; import { IntroSiteIframe } from './intro-site-iframe'; import { getAdminSetting } from '~/utils/admin-settings'; import { navigateOrParent } from '../utils'; import { ThemeSwitchWarningModal } from '~/customize-store/intro/warning-modals'; import { trackEvent } from '../tracking'; export const BaseIntroBanner = ( { bannerTitle, bannerText, bannerClass, showAIDisclaimer, buttonIsLink, bannerButtonOnClick, bannerButtonText, secondaryButton, previewBanner, children, }: { bannerTitle: string; bannerText: string; bannerClass: string; showAIDisclaimer: boolean; buttonIsLink?: boolean; bannerButtonOnClick?: () => void; bannerButtonText?: string; secondaryButton?: React.ReactNode; previewBanner?: React.ReactNode; children?: React.ReactNode; } ) => { return (

{ bannerTitle }

{ bannerText }

{ bannerButtonText && ( ) } { secondaryButton } { showAIDisclaimer && (

{ interpolateComponents( { mixedString: __( 'Powered by experimental AI. {{link}}Learn more{{/link}}', 'woocommerce' ), components: { link: ( ), }, } ) }

) }
{ children }
{ previewBanner }
); }; export const NetworkOfflineBanner = () => { return ( {} } showAIDisclaimer={ true } /> ); }; export const JetpackOfflineBanner = ( { sendEvent, }: { sendEvent: React.ComponentProps< typeof Intro >[ 'sendEvent' ]; } ) => { return ( { sendEvent( { type: 'JETPACK_OFFLINE_HOWTO', } ); } } bannerButtonText={ __( 'Find out how', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const ExistingThemeBanner = ( { setOpenDesignChangeWarningModal, }: { setOpenDesignChangeWarningModal: ( arg0: boolean ) => void; } ) => { return ( { setOpenDesignChangeWarningModal( true ); } } bannerButtonText={ __( 'Design with AI', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const DefaultBanner = ( { sendEvent, }: { sendEvent: React.ComponentProps< typeof Intro >[ 'sendEvent' ]; } ) => { return ( { sendEvent( { type: 'DESIGN_WITH_AI', } ); } } bannerButtonText={ __( 'Design with AI', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const ThemeHasModsBanner = ( { setOpenDesignChangeWarningModal, }: { setOpenDesignChangeWarningModal: ( arg0: boolean ) => void; } ) => { return ( { setOpenDesignChangeWarningModal( true ); } } bannerButtonText={ __( 'Design with AI', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const NoAIBanner = ( { redirectToCYSFlow, }: { redirectToCYSFlow: () => void; } ) => { const [ isModalOpen, setIsModalOpen ] = useState( false ); interface Theme { is_block_theme?: boolean; stylesheet?: string; } const currentTheme = useSelect( ( select ) => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return select( 'core' ).getCurrentTheme() as Theme; }, [] ); const isDefaultTheme = currentTheme?.stylesheet === 'twentytwentyfour'; return ( <> { if ( ! isDefaultTheme ) { setIsModalOpen( true ); } else { redirectToCYSFlow(); } } } showAIDisclaimer={ false } /> { isModalOpen && ( ) } ); }; export const ExistingAiThemeBanner = ( { setOpenDesignChangeWarningModal, }: { setOpenDesignChangeWarningModal: ( arg0: boolean ) => void; } ) => { const secondaryButton = ( ); const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1'; return ( { trackEvent( 'customize_your_store_intro_customize_click' ); navigateOrParent( window, getNewPath( { customizing: true }, '/customize-store/assembler-hub', {} ) ); } } bannerButtonText={ __( 'Customize', 'woocommerce' ) } secondaryButton={ secondaryButton } showAIDisclaimer={ true } >
); }; export const ExistingNoAiThemeBanner = () => { const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1'; interface Theme { is_block_theme?: boolean; } const currentTheme = useSelect( ( select ) => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return select( 'core' ).getCurrentTheme() as Theme; }, [] ); const isBlockTheme = currentTheme?.is_block_theme; return ( { trackEvent( 'customize_your_store_intro_customize_click', { theme_type: isBlockTheme ? 'block' : 'classic', } ); if ( isBlockTheme ) { navigateOrParent( window, getNewPath( { customizing: true }, '/customize-store/assembler-hub', {} ) ); } else { navigateOrParent( window, 'customize.php?return=/wp-admin/themes.php' ); } } } bannerButtonText={ __( 'Customize your theme', 'woocommerce' ) } showAIDisclaimer={ false } previewBanner={ } > ); };