import { Card, CardContent } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { cn } from "@/lib/utils"; import { FolderIcon } from "lucide-react"; import React, { type ChangeEvent, useRef } from "react"; interface DropzoneProps extends Omit< React.InputHTMLAttributes, "value" | "onChange" > { classNameWrapper?: string; className?: string; dropMessage: string; onChange: (acceptedFiles: FileList | null) => void; } export const Dropzone = React.forwardRef( ({ className, classNameWrapper, dropMessage, onChange, ...props }, ref) => { const inputRef = useRef(null); // Function to handle drag over event const handleDragOver = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); onChange(null); }; // Function to handle drop event const handleDrop = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); const { files } = e.dataTransfer; if (inputRef.current) { inputRef.current.files = files; onChange(files); } }; // Function to simulate a click on the file input element const handleButtonClick = () => { if (inputRef.current) { inputRef.current.click(); } }; return (
{dropMessage} ) => onChange(e.target.files) } />
); }, );