/** * External dependencies */ import { useState } from '@wordpress/element'; import { Button, Modal, CheckboxControl, TextareaControl, } from '@wordpress/components'; import apiFetch from '@wordpress/api-fetch'; import { recordEvent } from '@woocommerce/tracks'; /** * Internal dependencies */ import strings from './strings'; /** * Provides a modal requesting customer feedback. * */ function ExitSurveyModal( { setExitSurveyModalOpen, }: { // eslint-disable-next-line @typescript-eslint/ban-types setExitSurveyModalOpen: Function; } ): JSX.Element | null { const [ isOpen, setOpen ] = useState( true ); const [ isHappyChecked, setHappyChecked ] = useState( false ); const [ isInstallChecked, setInstallChecked ] = useState( false ); const [ isMoreInfoChecked, setMoreInfoChecked ] = useState( false ); const [ isAnotherTimeChecked, setAnotherTimeChecked ] = useState( false ); const [ isSomethingElseChecked, setSomethingElseChecked ] = useState( false ); const [ comments, setComments ] = useState( '' ); const closeModal = () => { setOpen( false ); setExitSurveyModalOpen( false ); }; const removeWCPayMenu = () => { apiFetch( { path: 'wc-admin/options', method: 'POST', data: { wc_calypso_bridge_payments_dismissed: 'yes', }, } ).then( () => { window.location.href = 'admin.php?page=wc-admin'; } ); setOpen( false ); }; const sendFeedback = () => { recordEvent( 'wcpay_exit_survey', { happy: isHappyChecked ? 'Yes' : 'No', install: isInstallChecked ? 'Yes' : 'No', moreInfo: isMoreInfoChecked ? 'Yes' : 'No', anotherTime: isAnotherTimeChecked ? 'Yes' : 'No', somethingElse: isSomethingElseChecked ? 'Yes' : 'No', comments, } ); removeWCPayMenu(); }; if ( ! isOpen ) { return null; } return (

{ strings.surveyIntro }

{ strings.surveyQuestion }

setComments( value ) } rows={ 3 } />
); } export default ExitSurveyModal;