import React, { useState, ForwardedRef, useEffect } from 'react'; import "../styles/variables.css" interface InputProps { message: string; onSendClick: (message: string, override: boolean) => void; onMicClick: () => void; inputDisabled: boolean; isRecording:boolean } const InputFrontend = React.forwardRef( ({ message, onSendClick, onMicClick, inputDisabled, isRecording}, ref: ForwardedRef) => { const [inputValue, setInputValue] = useState(''); useEffect(() => { setInputValue(message); }, [message]); const handleInputChange = (e: React.ChangeEvent) => { setInputValue(e.target.value); }; const handleKeyDown = (event: React.KeyboardEvent) => { if (!inputDisabled) { if (event.key === 'Enter') { onSendClick(inputValue, false); // Call the function passed via props setInputValue(''); // Optionally clear input after submission event.preventDefault(); // Prevent default action (e.g., form submission) } } }; const styles = { } return (
); } ); export default InputFrontend;