import React, { useCallback } from 'react'; import { useDropzone } from 'react-dropzone'; const FileDropZone = ({ onFileDrop }) => { const onDrop = useCallback(acceptedFiles => { acceptedFiles.forEach(file => { const reader = new FileReader(); reader.onload = () => { const fileContent = reader.result; onFileDrop({ content: fileContent, type: file.type || 'text/plain', // Fallback for files without type name: file.name }); }; reader.readAsText(file); }); }, [onFileDrop]); const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, accept: { 'text/plain': ['.txt'], 'application/json': ['.json'], 'text/yaml': ['.yml', '.yaml'], 'text/x-yaml': ['.yml', '.yaml'] }, multiple: false }); return (
{isDragActive ? (

Drop the file here...

) : (

Drag & drop a file here, or click to select

Accepted files: .txt, .json, .yml, .yaml

)}
); }; export default FileDropZone;