2023-10-09 05:19:08 +00:00
/ * *
* External dependencies
* /
import { Button , Modal } from '@wordpress/components' ;
import { Sender } from 'xstate' ;
import { __ } from '@wordpress/i18n' ;
import { Link } from '@woocommerce/components' ;
import { createInterpolateElement } from '@wordpress/element' ;
2023-11-09 01:32:47 +00:00
import { recordEvent } from '@woocommerce/tracks' ;
2023-10-09 05:19:08 +00:00
/ * *
* Internal dependencies
* /
import { customizeStoreStateMachineEvents } from '..' ;
import { ADMIN_URL } from '~/utils/admin-settings' ;
export const DesignChangeWarningModal = ( {
setOpenDesignChangeWarningModal ,
sendEvent ,
classname = 'woocommerce-customize-store__design-change-warning-modal' ,
} : {
setOpenDesignChangeWarningModal : ( arg0 : boolean ) = > void ;
sendEvent : Sender < customizeStoreStateMachineEvents > ;
classname? : string ;
} ) = > {
return (
< Modal
className = { classname }
title = { __ (
'Are you sure you want to start a new design?' ,
'woocommerce'
) }
onRequestClose = { ( ) = > setOpenDesignChangeWarningModal ( false ) }
shouldCloseOnClickOutside = { false }
>
< p >
{ createInterpolateElement (
__ (
2023-10-30 10:05:17 +00:00
"The Store 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>." ,
2023-10-09 05:19:08 +00:00
'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 >
< / Modal >
) ;
} ;
export const StartNewDesignWarningModal = ( {
setOpenDesignChangeWarningModal ,
sendEvent ,
classname = 'woocommerce-customize-store__design-change-warning-modal' ,
} : {
setOpenDesignChangeWarningModal : ( arg0 : boolean ) = > void ;
sendEvent : Sender < customizeStoreStateMachineEvents > ;
classname? : string ;
} ) = > {
return (
< Modal
className = { classname }
title = { __ (
'Are you sure you want to start a new design?' ,
'woocommerce'
) }
onRequestClose = { ( ) = > setOpenDesignChangeWarningModal ( false ) }
shouldCloseOnClickOutside = { false }
>
< p >
{ createInterpolateElement (
__ (
2023-10-30 10:05:17 +00:00
"The Store 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>." ,
2023-10-09 05:19:08 +00:00
'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 >
< / Modal >
) ;
} ;
export const StartOverWarningModal = ( {
setOpenDesignChangeWarningModal ,
sendEvent ,
classname = 'woocommerce-customize-store__design-change-warning-modal' ,
} : {
setOpenDesignChangeWarningModal : ( arg0 : boolean ) = > void ;
sendEvent : Sender < customizeStoreStateMachineEvents > ;
classname? : string ;
} ) = > {
return (
< Modal
className = { classname }
title = { __ (
'Are you sure you want to start over?' ,
'woocommerce'
) }
onRequestClose = { ( ) = > setOpenDesignChangeWarningModal ( false ) }
shouldCloseOnClickOutside = { false }
>
< p >
{ createInterpolateElement (
__ (
"You'll be asked to provide your business info again, and will lose your existing AI design. If you want to customize your existing design, 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
2023-11-09 01:32:47 +00:00
onClick = { ( ) = > {
sendEvent ( { type : 'DESIGN_WITH_AI' } ) ;
recordEvent (
'customize_your_store_intro_start_again_click'
) ;
} }
2023-10-09 05:19:08 +00:00
variant = "primary"
>
{ __ ( 'Start again' , 'woocommerce' ) }
< / Button >
< / div >
< / Modal >
) ;
} ;
2024-03-12 10:03:08 +00:00
export const ThemeSwitchWarningModal = ( {
setIsModalOpen ,
2024-03-15 08:17:20 +00:00
redirectToCYSFlow ,
2024-03-12 10:03:08 +00:00
} : {
setIsModalOpen : ( arg0 : boolean ) = > void ;
2024-03-15 08:17:20 +00:00
redirectToCYSFlow : ( ) = > void ;
2024-03-12 10:03:08 +00:00
} ) = > {
return (
< Modal
className = {
'woocommerce-customize-store__theme-switch-warning-modal'
}
title = { __ (
'Are you sure you want to design a new theme?' ,
'woocommerce'
) }
onRequestClose = { ( ) = > setIsModalOpen ( false ) }
shouldCloseOnClickOutside = { false }
>
< p >
{ __ (
'Your active theme will be changed and you could lose any changes you’ ve made to it.' ,
'woocommerce'
) }
< / p >
< div className = "woocommerce-customize-store__theme-switch-warning-modal-footer" >
< Button
onClick = { ( ) = > {
setIsModalOpen ( false ) ;
} }
variant = "link"
>
{ __ ( 'Cancel' , 'woocommerce' ) }
< / Button >
< Button
onClick = { ( ) = > {
setIsModalOpen ( false ) ;
recordEvent (
'customize_your_store_agree_to_theme_switch_click'
) ;
2024-03-15 08:17:20 +00:00
redirectToCYSFlow ( ) ;
2024-03-12 10:03:08 +00:00
} }
variant = "primary"
>
{ __ ( 'Design a new theme' , 'woocommerce' ) }
< / Button >
< / div >
< / Modal >
) ;
} ;