/** * WordPress dependencies */ import { Button } from '@safe-wordpress/components'; import { useDispatch } from '@safe-wordpress/data'; import { useRef, useState } from '@safe-wordpress/element'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import confetti from 'canvas-confetti'; import { store as NC_SOCIAL_EDITOR, SocialMessageEditor, } from '@nelio-content/social-message-editor'; /** * Internal dependencies */ import './style.scss'; type MessageCreationStepProps = { readonly isDisabled: boolean; readonly previousStep: () => void; readonly nextStep: () => void; readonly onFinish: () => void; }; export const MessageCreationStep = ( { isDisabled, previousStep, nextStep, onFinish, }: MessageCreationStepProps ): JSX.Element => { const ref = useRef< HTMLButtonElement >(); const [ wasMessageCreated, setWasMessageCreated ] = useState( false ); const [ isLoading, setIsLoading ] = useState( false ); const { openNewSocialMessageEditor } = useDispatch( NC_SOCIAL_EDITOR ); return (
{ wasMessageCreated ? _x( 'Great! Your First Message is Ready', 'user', 'nelio-content' ) : _x( 'Schedule Your First Social Message', 'user', 'nelio-content' ) }

{ wasMessageCreated ? _x( 'You have successfully created your first content promotion message. Now you can view it in your calendar.', 'user', 'nelio-content' ) : _x( 'Now you can create and schedule your first content promotion message.', 'user', 'nelio-content' ) }

{ ! wasMessageCreated && ( <> setWasMessageCreated( true ) } /> ) }
); }; const getOrigin = ( element?: HTMLElement ) => { const rect = element?.getBoundingClientRect(); const vw = window.innerWidth || document.documentElement.clientWidth || 1; const vh = window.innerHeight || document.documentElement.clientHeight || 1; const x = rect ? Math.min( Math.max( ( rect.left + rect.width / 2 ) / vw, 0 ), 1 ) : 0.5; const y = rect ? Math.min( Math.max( ( rect.top + rect.height / 2 ) / vh, 0 ), 1 ) : 0.5; return { x, y }; };