2023-09-20 06:36:20 +00:00
/ * *
* External dependencies
* /
import { __ } from '@wordpress/i18n' ;
import { chevronLeft } from '@wordpress/icons' ;
2023-09-29 23:03:50 +00:00
import { createInterpolateElement , useState } from '@wordpress/element' ;
2023-09-29 07:44:22 +00:00
import { Button } from '@wordpress/components' ;
2023-09-29 23:03:50 +00:00
import { Link } from '@woocommerce/components' ;
2023-09-20 06:36:20 +00:00
2023-08-18 05:30:25 +00:00
/ * *
* Internal dependencies
* /
import { CustomizeStoreComponent } from '../types' ;
2023-09-29 23:03:50 +00:00
import { DesignChangeWarningModal } from './design-change-warning-modal' ;
2023-09-20 06:36:20 +00:00
import './intro.scss' ;
2023-09-29 23:03:50 +00:00
import { ADMIN_URL } from '~/utils/admin-settings' ;
2023-09-20 06:36:20 +00:00
2023-08-18 05:30:25 +00:00
export type events =
| { type : 'DESIGN_WITH_AI' }
| { type : 'CLICKED_ON_BREADCRUMB' }
| { type : 'SELECTED_BROWSE_ALL_THEMES' }
2023-09-29 07:44:22 +00:00
| { type : 'SELECTED_ACTIVE_THEME' ; payload : { theme : string } }
2023-08-18 05:30:25 +00:00
| { type : 'SELECTED_NEW_THEME' ; payload : { theme : string } } ;
export * as actions from './actions' ;
export * as services from './services' ;
export const Intro : CustomizeStoreComponent = ( { sendEvent , context } ) = > {
const {
2023-09-29 23:03:50 +00:00
intro : { themeCards , activeThemeHasMods , customizeStoreTaskCompleted } ,
2023-08-18 05:30:25 +00:00
} = context ;
2023-09-20 06:36:20 +00:00
2023-09-29 23:03:50 +00:00
const [ openDesignChangeWarningModal , setOpenDesignChangeWarningModal ] =
useState ( false ) ;
2023-08-18 05:30:25 +00:00
return (
< >
2023-09-29 23:03:50 +00:00
{ openDesignChangeWarningModal && (
< DesignChangeWarningModal
title = { __ (
'Are you sure you want to start a new design?' ,
'woocommerce'
) }
isOpen = { true }
onRequestClose = { ( ) = > {
setOpenDesignChangeWarningModal ( false ) ;
} }
>
< p >
{ createInterpolateElement (
__ (
"The [AI designer*] will create a new store design for you, and you'll lose any changes you've made to your active theme. If you'd prefer to continue editing your theme, you can do so via the <EditorLink>Editor</EditorLink>." ,
'woocommerce'
) ,
{
EditorLink : (
< Link
onClick = { ( ) = > {
window . open (
` ${ ADMIN_URL } site-editor.php ` ,
'_blank'
) ;
return false ;
} }
href = ""
/ >
) ,
}
) }
< / p >
< div className = "woocommerce-customize-store__design-change-warning-modal-footer" >
< Button
onClick = { ( ) = >
setOpenDesignChangeWarningModal ( false )
}
variant = "link"
>
{ __ ( 'Cancel' , 'woocommerce' ) }
< / Button >
< Button
onClick = { ( ) = >
sendEvent ( { type : 'DESIGN_WITH_AI' } )
}
variant = "primary"
>
{ __ ( 'Design with AI' , 'woocommerce' ) }
< / Button >
< / div >
< / DesignChangeWarningModal >
) }
2023-09-20 06:36:20 +00:00
< div className = "woocommerce-customize-store-header" >
< h1 > { 'Site title' } < / h1 >
< / div >
< div className = "woocommerce-customize-store-container" >
< div className = "woocommerce-customize-store-sidebar" >
< div className = "woocommerce-customize-store-sidebar__title" >
< button
onClick = { ( ) = > {
sendEvent ( 'CLICKED_ON_BREADCRUMB' ) ;
} }
>
{ chevronLeft }
< / button >
{ __ ( 'Customize your store' , 'woocommerce' ) }
< / div >
< p >
{ __ (
'Create a store that reflects your brand and business. Select one of our professionally designed themes to customize, or create your own using AI.' ,
'woocommerce'
) }
< / p >
< / div >
< div className = "woocommerce-customize-store-main" >
< div className = "woocommerce-customize-store-banner" >
< div
className = { ` woocommerce-customize-store-banner-content ` }
>
< h1 >
{ __ (
'Use the power of AI to design your store' ,
'woocommerce'
) }
< / h1 >
< p >
{ __ (
'Design the look of your store, create pages, and generate copy using our built-in AI tools.' ,
'woocommerce'
) }
< / p >
< button
2023-09-29 23:03:50 +00:00
onClick = { ( ) = > {
if (
activeThemeHasMods &&
! customizeStoreTaskCompleted
) {
setOpenDesignChangeWarningModal ( true ) ;
} else {
sendEvent ( { type : 'DESIGN_WITH_AI' } ) ;
}
} }
2023-09-20 06:36:20 +00:00
>
{ __ ( 'Design with AI' , 'woocommerce' ) }
< / button >
< / div >
< / div >
< p >
{ __ (
'Or select a professionally designed theme to customize and make your own.' ,
'woocommerce'
) }
< / p >
< div className = "woocommerce-customize-store-theme-cards" >
{ themeCards ? . map ( ( themeCard ) = > (
2023-09-29 07:44:22 +00:00
< Button
variant = "link"
className = "theme-card"
key = { themeCard . slug }
onClick = { ( ) = > {
if ( themeCard . isActive ) {
sendEvent ( {
type : 'SELECTED_ACTIVE_THEME' ,
payload : { theme : themeCard.slug } ,
} ) ;
} else {
sendEvent ( {
type : 'SELECTED_NEW_THEME' ,
payload : { theme : themeCard.slug } ,
} ) ;
}
} }
>
2023-09-20 06:36:20 +00:00
< div >
< img
src = { themeCard . image }
alt = { themeCard . description }
/ >
< / div >
< h2 className = "theme-card__title" >
{ themeCard . name }
< / h2 >
2023-09-29 07:44:22 +00:00
< / Button >
2023-09-20 06:36:20 +00:00
) ) }
< / div >
< div className = "woocommerce-customize-store-browse-themes" >
< button
onClick = { ( ) = >
sendEvent ( {
type : 'SELECTED_BROWSE_ALL_THEMES' ,
} )
}
>
{ __ ( 'Browse all themes' , 'woocommerce' ) }
< / button >
< / div >
< / div >
< / div >
2023-08-18 05:30:25 +00:00
< / >
) ;
} ;