"use client" import * as React from "react" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Loader2 } from "lucide-react" interface FileUploadAreaProps { onFileSelected?: (file: File) => void isLoading?: boolean className?: string } const FileUploadArea = React.forwardRef( ({ onFileSelected, isLoading = false, className }, ref) => { const [isDragging, setIsDragging] = React.useState(false) const fileInputRef = React.useRef(null) const handleDragOver = (e: React.DragEvent) => { e.preventDefault() setIsDragging(true) } const handleDragLeave = (e: React.DragEvent) => { e.preventDefault() setIsDragging(false) } const handleDrop = (e: React.DragEvent) => { e.preventDefault() setIsDragging(false) const files = Array.from(e.dataTransfer.files) if (files.length > 0 && onFileSelected) { onFileSelected(files[0]) } } const handleFileSelect = (e: React.ChangeEvent) => { const files = Array.from(e.target.files || []) if (files.length > 0 && onFileSelected) { onFileSelected(files[0]) } } const handleClick = () => { if (!isLoading) { fileInputRef.current?.click() } } return (
{isLoading && (
)}

{isLoading ? "Processing file..." : "Drop files here or click to upload"}

{isLoading ? "Please wait while your file is being processed" : ""}

{!isLoading && ( )}
) } ) FileUploadArea.displayName = "FileUploadArea" export { FileUploadArea }