import React from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { changeAccountNoteComment, submitAccountNote } from 'soapbox/actions/account-notes'; import { closeModal } from 'soapbox/actions/modals'; import { Modal, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; const messages = defineMessages({ placeholder: { id: 'account_note.placeholder', defaultMessage: 'No comment provided' }, save: { id: 'account_note.save', defaultMessage: 'Save' }, }); const getAccount = makeGetAccount(); const AccountNoteModal = () => { const intl = useIntl(); const dispatch = useAppDispatch(); const isSubmitting = useAppSelector((state) => state.account_notes.edit.isSubmitting); const account = useAppSelector((state) => getAccount(state, state.account_notes.edit.account!)); const comment = useAppSelector((state) => state.account_notes.edit.comment); const onClose = () => { dispatch(closeModal('ACCOUNT_NOTE')); }; const handleCommentChange: React.ChangeEventHandler = e => { dispatch(changeAccountNoteComment(e.target.value)); }; const handleSubmit = () => { dispatch(submitAccountNote()); }; const handleKeyDown: React.KeyboardEventHandler = e => { if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) { handleSubmit(); } }; return ( } onClose={onClose} confirmationAction={handleSubmit} confirmationText={intl.formatMessage(messages.save)} confirmationDisabled={isSubmitting} >