From 4092f856a6f973285210cca3db105d4d49df101d Mon Sep 17 00:00:00 2001 From: Wallys Ferreira Date: Sat, 27 Jan 2024 09:21:17 -0300 Subject: [PATCH] feat: upload multiple files (#116) * feat: add property 'multiple' to file input * feat: sends multiple documents or images to api * fix: show icon for each file being uploaded * fix: refresh page after uploading all files * chore: add semicolons * fix: cards overflow * chore: add EOF * fix: prevent file name overflow in card Co-authored-by: Kevin Nielsen * chore: fix indentation --------- Co-authored-by: Kevin Nielsen --- frontend/src/components/docs-input.tsx | 32 +++++++++--------- frontend/src/components/image-input.tsx | 31 +++++++++--------- frontend/src/components/upload-preview.tsx | 33 +++++++++++++++++++ frontend/src/components/upload.tsx | 38 ++++++++++++---------- frontend/src/index.css | 6 +++- 5 files changed, 89 insertions(+), 51 deletions(-) create mode 100644 frontend/src/components/upload-preview.tsx diff --git a/frontend/src/components/docs-input.tsx b/frontend/src/components/docs-input.tsx index 2d5893d..ceaec0d 100644 --- a/frontend/src/components/docs-input.tsx +++ b/frontend/src/components/docs-input.tsx @@ -1,37 +1,35 @@ import { useState } from "react"; -import { FileText } from "lucide-react"; +import UploadPreview from "./upload-preview"; const DocsInput: React.FC<{ fileRef: React.RefObject; }> = ({ fileRef }) => { - const [fileName, setFileName] = useState(undefined); + const [fileNames, setFileNames] = useState([]); - const getFileName = () => { + const getFileNames = () => { if (fileRef.current?.files != null) { - setFileName(fileRef.current.files[0].name); + let names = []; + + for (let file of fileRef.current.files) { + names.push(file.name); + } + + setFileNames(names); } }; return ( -
-
- {fileName ? ( -
- - {fileName} -
- ) : ( -
- -
- )} +
+
+