From 719c0312126c360c88d126535a5676481d008bc1 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Sat, 8 Jun 2024 13:41:29 -0300 Subject: [PATCH] feat: Add drag and drop file upload functionality to chat input This commit adds the drag and drop file upload functionality to the chat input component in the IOModal. It allows users to drag and drop files into the chat input area for uploading. The files are then processed and added to the chat message. Files are validated to ensure they have the correct file extensions (png, jpg, jpeg, gif, bmp, webp) before uploading. If an invalid file is dropped, an error message is displayed. This feature improves the user experience by providing a convenient way to upload files in the chat input. Fixes #2115 --- .../components/buttonSendWrapper/index.tsx | 26 +++++++++++++++--- .../chatInput/hooks/use-drag-and-drop.tsx | 27 ++++++++++++++++--- .../components/chatView/chatInput/index.tsx | 1 + .../IOModal/components/chatView/index.tsx | 3 ++- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx index ff93a9f7b..52a3ff4dc 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx @@ -1,14 +1,25 @@ import IconComponent from "../../../../../../../components/genericIconComponent"; import { Case } from "../../../../../../../shared/components/caseComponent"; +import { FilePreviewType } from "../../../../../../../types/components"; import { classNames } from "../../../../../../../utils/utils"; +type ButtonSendWrapperProps = { + send: () => void; + lockChat: boolean; + noInput: boolean; + saveLoading: boolean; + chatValue: string; + files: FilePreviewType[]; +}; + const ButtonSendWrapper = ({ send, lockChat, noInput, saveLoading, chatValue, -}) => { + files, +}: ButtonSendWrapperProps) => { return (