import React, { useState, useCallback } from 'react'; import { useDropzone } from 'react-dropzone'; import { Upload, FileText, X } from 'lucide-react'; import { motion } from 'framer-motion'; const InputSection = ({ onAnalyze }) => { const [text, setText] = useState(''); const [activeTab, setActiveTab] = useState('text'); const [file, setFile] = useState(null); const onDrop = useCallback((acceptedFiles) => { if (acceptedFiles?.length > 0) { setFile(acceptedFiles[0]); } }, []); const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, accept: { 'text/plain': ['.txt'], 'application/pdf': ['.pdf'] }, maxFiles: 1 }); const handleAnalyze = () => { if (activeTab === 'text' && text.trim()) { onAnalyze({ type: 'text', content: text }); } else if (activeTab === 'file' && file) { onAnalyze({ type: 'file', content: file }); } }; return (
{file.name}
{(file.size / 1024).toFixed(2)} KB
Drag & Drop file
.txt .pdf