|
1 | 1 | import { useState } from "react";
|
2 |
| -import { FileText } from "lucide-react"; |
| 2 | +import UploadPreview from "./upload-preview"; |
3 | 3 |
|
4 | 4 | const DocsInput: React.FC<{
|
5 | 5 | fileRef: React.RefObject<HTMLInputElement>;
|
6 | 6 | }> = ({ fileRef }) => {
|
7 |
| - const [fileName, setFileName] = useState<undefined | string>(undefined); |
| 7 | + const [fileNames, setFileNames] = useState<string[]>([]); |
8 | 8 |
|
9 |
| - const getFileName = () => { |
| 9 | + const getFileNames = () => { |
10 | 10 | if (fileRef.current?.files != null) {
|
11 |
| - setFileName(fileRef.current.files[0].name); |
| 11 | + let names = []; |
| 12 | + |
| 13 | + for (let file of fileRef.current.files) { |
| 14 | + names.push(file.name); |
| 15 | + } |
| 16 | + |
| 17 | + setFileNames(names); |
12 | 18 | }
|
13 | 19 | };
|
14 | 20 |
|
15 | 21 | return (
|
16 |
| - <div className="my-8 flex flex-col justify-center items-center h-full"> |
17 |
| - <div className="w-full h-full mb-4 flex justify-center items-center"> |
18 |
| - {fileName ? ( |
19 |
| - <div className="border rounded-lg w-64 min-h-[264px] max-w-[256px] flex flex-col overflow-hidden justify-center items-center"> |
20 |
| - <FileText size="128" /> |
21 |
| - {fileName} |
22 |
| - </div> |
23 |
| - ) : ( |
24 |
| - <div className="border rounded-lg w-64 min-h-[264px] max-w-[256px] flex justify-center items-center"> |
25 |
| - <FileText size="128" /> |
26 |
| - </div> |
27 |
| - )} |
| 22 | + <div className="my-8 flex max-h-[691px] flex-col justify-center items-center h-full"> |
| 23 | + <div className="w-full h-full mb-4 flex justify-center items-center overflow-hidden"> |
| 24 | + <UploadPreview fileNames={fileNames} type="docs"/> |
28 | 25 | </div>
|
29 | 26 | <label htmlFor="document" className="flex flex-col">
|
30 | 27 | Select Document
|
31 | 28 | <input
|
32 |
| - onChange={getFileName} |
| 29 | + onChange={getFileNames} |
33 | 30 | type="file"
|
34 | 31 | accept="text/plain, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/pdf, application/rtf, application/x-freearc"
|
| 32 | + multiple |
35 | 33 | name="document"
|
36 | 34 | id="document"
|
37 | 35 | aria-label="Select document"
|
|
0 commit comments