import React from 'react'; import { motion } from 'framer-motion'; import { useTranslation } from 'react-i18next'; import { MenuIcon, PaperAirplaneIcon } from '@heroicons/react/outline'; import { connection } from '../connection'; import { useAppDispatch, useAppSelector } from '../hooks/redux'; import { toggleSidebar } from '../slices/appSlice'; export const MessageBox = (): JSX.Element => { const ready = useAppSelector((state) => state.meshtastic.ready); const [currentMessage, setCurrentMessage] = React.useState(''); const sendMessage = () => { if (ready) { connection.sendText(currentMessage, undefined, true); setCurrentMessage(''); } }; const { t } = useTranslation(); const dispatch = useAppDispatch(); return (
{ dispatch(toggleSidebar()); }} >
{ e.preventDefault(); sendMessage(); }} > {ready} { setCurrentMessage(e.target.value); }} className={`p-3 placeholder-gray-400 text-gray-700 relative rounded-3xl border shadow-md focus:outline-none w-full pr-10 ${ ready ? 'cursor-text' : 'cursor-not-allowed' }`} />
); };