diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx index 069d11f73..42c439941 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useRef, useState } from "react"; import { CHAT_INPUT_PLACEHOLDER, CHAT_INPUT_PLACEHOLDER_SEND, @@ -12,10 +12,12 @@ import { import FilePreview from "../filePreviewChat"; import ButtonSendWrapper from "./components/buttonSendWrapper"; import TextAreaWrapper from "./components/textAreaWrapper"; +import UploadFileButton from "./components/uploadFileButton"; import { getClassNamesFilePreview } from "./helpers/get-class-file-preview"; import useAutoResizeTextArea from "./hooks/use-auto-resize-text-area"; import useDragAndDrop from "./hooks/use-drag-and-drop"; import useFocusOnUnlock from "./hooks/use-focus-unlock"; +import useHandleFileChange from "./hooks/use-handle-file-change"; import useUpload from "./hooks/use-upload"; export default function ChatInput({ lockChat, @@ -31,15 +33,17 @@ export default function ChatInput({ const [files, setFiles] = useState([]); const [isDragging, setIsDragging] = useState(false); const [inputFocus, setInputFocus] = useState(false); + const fileInputRef = useRef(null); useFocusOnUnlock(lockChat, inputRef); useAutoResizeTextArea(chatValue, inputRef); useUpload(uploadFile, currentFlowId, setFiles); + const { handleFileChange } = useHandleFileChange(setFiles, currentFlowId); const { dragOver, dragEnter, dragLeave, onDrop } = useDragAndDrop( setIsDragging, setFiles, - currentFlowId + currentFlowId, ); const send = () => { @@ -62,6 +66,10 @@ export default function ChatInput({ const classNameFilePreview = getClassNamesFilePreview(inputFocus); + const handleButtonClick = () => { + fileInputRef.current!.click(); + }; + return (
@@ -82,6 +90,7 @@ export default function ChatInput({ inputRef={inputRef} setInputFocus={setInputFocus} files={files} + isDragging={isDragging} />
@@ -93,6 +102,12 @@ export default function ChatInput({ chatValue={chatValue} />
+ +
{files.length > 0 && (