/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; import classNames from 'classnames'; import { Button } from '@wordpress/components'; import { getNewPath } from '@woocommerce/navigation'; import { recordEvent } from '@woocommerce/tracks'; 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 { ADMIN_URL, getAdminSetting } from '~/utils/admin-settings'; import { navigateOrParent } from '../utils'; import { ThemeSwitchWarningModal } from '~/customize-store/intro/warning-modals'; 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 = () => { const [ isModalOpen, setIsModalOpen ] = useState( false ); interface Theme { stylesheet?: string; } const currentTheme = useSelect( ( select ) => { return select( 'core' ).getCurrentTheme() as Theme; }, [] ); const isDefaultTheme = currentTheme?.stylesheet === 'twentytwentyfour'; const customizeStoreDesignUrl = addQueryArgs( `${ ADMIN_URL }admin.php`, { page: 'wc-admin', path: '/customize-store/design', } ); return ( <> { if ( ! isDefaultTheme ) { setIsModalOpen( true ); } else { window.location.href = customizeStoreDesignUrl; } } } showAIDisclaimer={ false } /> { isModalOpen && ( ) } ); }; export const ExistingAiThemeBanner = ( { setOpenDesignChangeWarningModal, }: { setOpenDesignChangeWarningModal: ( arg0: boolean ) => void; } ) => { const secondaryButton = ( ); const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1'; return ( { recordEvent( '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'; return ( { recordEvent( 'customize_your_store_intro_customize_click' ); navigateOrParent( window, getNewPath( { customizing: true }, '/customize-store/assembler-hub', {} ) ); } } bannerButtonText={ __( 'Customize your theme', 'woocommerce' ) } showAIDisclaimer={ false } previewBanner={ } > ); };