/** * WordPress dependencies */ import { Button, ExternalLink, TextareaControl, TextControl, } from '@safe-wordpress/components'; import { _x } from '@safe-wordpress/i18n'; import { isEmail } from '@safe-wordpress/url'; import { addFreeTracker } from '@nab/utils'; /** * Internal dependencies */ import type { State, Submission } from './types'; export type ContactFormProps = { readonly attributes: State; readonly closeForm: () => void; readonly onSubmit: ( submission: Submission ) => void; readonly setAttributes: ( attrs: Partial< State > ) => void; }; export const ContactForm = ( { attributes: { description = '', email = '', isTicketSubmitting = false, submissionStatus = 'none', }, closeForm, onSubmit, setAttributes, }: ContactFormProps ): JSX.Element => { const isSubmitDisabled = isTicketSubmitting || ! description.trim() || ! isEmail( email ); const reset = () => { setAttributes( { email: '', description: '', isTicketSubmitting: false, submissionStatus: 'none', mode: 'questions', } ); closeForm(); }; if ( 'error' === submissionStatus ) { return (

{ _x( 'Error', 'text', 'nelio-ab-testing' ) }

{ _x( 'Something went wrong and the ticket couldn’t be created.', 'text', 'nelio-ab-testing' ) }{ ' ' } { _x( 'Open ticket in our website', 'user', 'nelio-ab-testing' ) }

); } if ( 'success' === submissionStatus ) { return (

{ _x( 'Ticket Successfully Submitted', 'text', 'nelio-ab-testing' ) }

{ _x( 'Your ticket has been successfully created. We’ll get back to you as soon as possible.', 'user', 'nelio-ab-testing' ) }

); } return (

{ _x( 'Contact Us', 'user', 'nelio-ab-testing' ) }

setAttributes( { description: value } ) } /> setAttributes( { email: value } ) } />
{ ' ' }
); };