import React, { FormEvent, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Paper, TextField, Button, Box } from '@material-ui/core'; import SendIcon from '@material-ui/icons/Send'; import ImageIcon from '@material-ui/icons/Image'; import Nui from '../../../../os/nui-events/utils/Nui'; interface IProps { onAddImageClick(): void; messageGroupId: string | undefined; } const MessageInput = ({ messageGroupId, onAddImageClick }: IProps) => { const { t } = useTranslation(); const [message, setMessage] = useState(''); const handleSubmit = (event: FormEvent) => { event.preventDefault(); if (message.trim()) { // don't allow the user to submit white space Nui.send('phone:sendMessage', { groupId: messageGroupId, message, }); setMessage(''); } }; if (!messageGroupId) return null; return (
setMessage(e.target.value)} placeholder={t('APPS_MESSAGES_NEW_MESSAGE')} inputRef={(input) => input && input.focus()} />
); }; export default MessageInput;