import React, { useCallback } from 'react';
import { useDropzone } from 'react-dropzone';
import { Upload, File, Image, Music, X } from 'lucide-react';
import { validateFile, formatFileSize } from '../../utils/fileValidation';
const FileUpload = ({ onFileSelect, multiple = false, acceptedTypes = [] }) => {
const onDrop = useCallback((acceptedFiles) => {
acceptedFiles.forEach(file => {
try {
validateFile(file);
onFileSelect(file);
} catch (error) {
alert(`Error with file ${file.name}: ${error.message}`);
}
});
}, [onFileSelect]);
const { getRootProps, getInputProps, isDragActive } = useDropzone({
onDrop,
multiple,
accept: acceptedTypes.length > 0 ? acceptedTypes.reduce((acc, type) => {
acc[type] = [];
return acc;
}, {}) : undefined
});
const getFileIcon = (file) => {
if (file.type.startsWith('image/')) return
Drop the files here...
) : ( <>Drag & drop files here
or click to select files
> )}