import React, { useRef, useState } from 'react'; import { UploadCloud, Image as ImageIcon, Video, X, Loader2 } from 'lucide-react'; const FileUpload = ({ onUpload, isProcessing, file }) => { const [dragActive, setDragActive] = useState(false); const inputRef = useRef(null); const handleDrag = (e) => { e.preventDefault(); e.stopPropagation(); if (e.type === "dragenter" || e.type === "dragover") { setDragActive(true); } else if (e.type === "dragleave") { setDragActive(false); } }; const handleDrop = (e) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); if (e.dataTransfer.files && e.dataTransfer.files[0]) { onUpload(e.dataTransfer.files[0]); } }; const handleChange = (e) => { e.preventDefault(); if (e.target.files && e.target.files[0]) { onUpload(e.target.files[0]); } }; const isVideo = file?.type.startsWith('video/'); return (
{!file ? (
inputRef.current.click()} >

Drag and drop feed here

Support for Image or Video formats

) : (
{isVideo ? (
)} {file && !isProcessing && ( )}
); }; // Add standard spin keyframes if not present if (typeof document !== 'undefined') { const style = document.createElement('style'); style.innerHTML = ` @keyframes spin { 100% { transform: rotate(360deg); } } `; document.head.appendChild(style); } export default FileUpload;