blob: 6980f5c835edd4585a9fc51c3464094c9cbed5dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
'use client';
import Dropzone from 'react-dropzone';
import UploadIcon from '@icons/upload.svg';
import { Button } from '@/components/ui';
import { useRef, useState } from 'react';
export function FileDropzone() {
// const [files, setFiles] = useState<File[]>([]);
const hiddenInputRef = useRef<HTMLInputElement | null>(null);
return (
<Dropzone
multiple
onDrop={(acceptedFiles: File[]) => {
// setFiles((prev) => [...prev, ...acceptedFiles]);
}}
>
{({ getRootProps, getInputProps }) => (
<div
{...getRootProps({
className:
'w-full h-[460px] justify-between p-7.5 border flex flex-col text-sm items-center rounded-[10px]',
})}
>
<input name="files" type="file" ref={hiddenInputRef} />
<input {...getInputProps()} />
<div className="flex flex-col justify-center items-center h-full w-full gap-2.5">
<UploadIcon />
<span>
Выбери файлы на компьютере или перетащи сюда. JPG,
PNG до 20MB.
</span>
<span>
{hiddenInputRef.current?.files?.length ?? 0}
</span>
</div>
<Button size={'lg'} className="justify-self-end">
Выбрать
</Button>
</div>
)}
</Dropzone>
);
}
|