import React , { useState } from 'react' ; import FormSelect from './FormSelect' ; import TellAFriend from '../TellAFriend' ; const FinishDonationMessage = ( { defaultSelectedValue , mobilization , widget , onClickDonate , ... ownProps } ) => { const [ value , setValue ] = useState ( defaultSelectedValue ) ; const [ success , setSuccess ] = useState ( false ) ; const onChange = ( e ) => { setValue ( e . currentTarget . value ) ; } ; if ( success ) { const message = ! ! value ? 'donation: ok' : 'donation: not ok' ; return ( < TellAFriend { ... ownProps } mobilization = { mobilization } widget = { widget } message = { message } / > ) ; } return ( < FormSelect mobilization = { mobilization } widget = { widget } onChange = { onChange } value = { value } onSubmit = { async ( value ) => { await onClickDonate ( value ) ; setValue ( value ) ; setSuccess ( true ) ; } } />); } ; export default FinishDonationMessage ;