2023-08-29 06:00:54 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useState } from '@wordpress/element';
|
2023-09-06 06:21:09 +00:00
|
|
|
import { TextareaControl, Button, Spinner } from '@wordpress/components';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { ProgressBar } from '@woocommerce/components';
|
2023-08-29 06:00:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { designWithAiStateMachineContext } from '../types';
|
2023-09-06 06:21:09 +00:00
|
|
|
import { CloseButton } from '../components/close-button/close-button';
|
|
|
|
import { aiWizardClosedBeforeCompletionEvent } from '../events';
|
2023-08-29 06:00:54 +00:00
|
|
|
|
|
|
|
export type businessInfoDescriptionCompleteEvent = {
|
|
|
|
type: 'BUSINESS_INFO_DESCRIPTION_COMPLETE';
|
|
|
|
payload: string;
|
|
|
|
};
|
|
|
|
export const BusinessInfoDescription = ( {
|
|
|
|
sendEvent,
|
|
|
|
context,
|
|
|
|
}: {
|
2023-09-06 06:21:09 +00:00
|
|
|
sendEvent: (
|
|
|
|
event:
|
|
|
|
| businessInfoDescriptionCompleteEvent
|
|
|
|
| aiWizardClosedBeforeCompletionEvent
|
|
|
|
) => void;
|
2023-08-29 06:00:54 +00:00
|
|
|
context: designWithAiStateMachineContext;
|
|
|
|
} ) => {
|
|
|
|
const [ businessInfoDescription, setBusinessInfoDescription ] = useState(
|
|
|
|
context.businessInfoDescription.descriptionText
|
|
|
|
);
|
2023-09-06 06:21:09 +00:00
|
|
|
const [ isRequesting, setIsRequesting ] = useState( false );
|
2023-08-29 06:00:54 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2023-09-06 06:21:09 +00:00
|
|
|
<ProgressBar
|
|
|
|
percent={ 20 }
|
|
|
|
color={ 'var(--wp-admin-theme-color)' }
|
|
|
|
bgcolor={ 'transparent' }
|
2023-08-29 06:00:54 +00:00
|
|
|
/>
|
2023-09-06 06:21:09 +00:00
|
|
|
<CloseButton
|
|
|
|
onClick={ () => {
|
2023-08-29 06:00:54 +00:00
|
|
|
sendEvent( {
|
2023-09-06 06:21:09 +00:00
|
|
|
type: 'AI_WIZARD_CLOSED_BEFORE_COMPLETION',
|
|
|
|
payload: { step: 'business-info-description' },
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
<div className="woocommerce-cys-design-with-ai woocommerce-cys-layout">
|
|
|
|
<div className="woocommerce-cys-page">
|
|
|
|
<h1>
|
|
|
|
{ __(
|
|
|
|
'Tell us a bit more about your business',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</h1>
|
|
|
|
<TextareaControl
|
|
|
|
onChange={ ( businessInfo ) => {
|
|
|
|
setBusinessInfoDescription( businessInfo );
|
|
|
|
} }
|
|
|
|
value={ businessInfoDescription }
|
|
|
|
/>
|
|
|
|
<div className="woocommerce-cys-design-with-ai-guide">
|
|
|
|
<p>
|
|
|
|
{ __(
|
2023-12-20 09:39:09 +00:00
|
|
|
'The more detail you provide, the better job our AI can do!',
|
2023-09-06 06:21:09 +00:00
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</p>
|
|
|
|
<p>{ __( 'Try to include:', 'woocommerce' ) }</p>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
{ __( 'What you want to sell', 'woocommerce' ) }
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
{ __(
|
|
|
|
'How many products you plan on displaying',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
{ __(
|
|
|
|
'What makes your business unique',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
{ __(
|
|
|
|
'Who your target audience is',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
onClick={ () => {
|
|
|
|
setIsRequesting( true );
|
|
|
|
sendEvent( {
|
|
|
|
type: 'BUSINESS_INFO_DESCRIPTION_COMPLETE',
|
|
|
|
payload: businessInfoDescription,
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
disabled={
|
|
|
|
businessInfoDescription.length === 0 || isRequesting
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{ isRequesting ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
__( 'Continue', 'woocommerce' )
|
|
|
|
) }
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-29 06:00:54 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|