import React, { useState } from 'react'; import Header from './components/Header'; import InputSection from './components/InputSection'; import Results from './components/Results'; function App() { const [result, setResult] = useState(null); const [loading, setLoading] = useState(false); const handleAnalyze = async (data) => { setLoading(true); try { let payload = {}; if (data.type === 'text') { payload = { text: data.content }; } // Note: File upload would need FormData, keeping it simple JSON for text for now const response = await fetch('/api/analyze/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(payload), }); if (!response.ok) { throw new Error('Analysis failed'); } const resultData = await response.json(); // Attach original text for the report setResult({ ...resultData, originalText: payload.text || "Uploaded File Content" }); } catch (error) { console.error("Error analyzing:", error); alert("Failed to connect to local backend. Make sure Django is running!"); } finally { setLoading(false); } }; const handleReset = () => { setResult(null); }; return ( <>
{!result && !loading && ( )} {loading && (

Analyzing patterns...

)} {result && ( )}
); } export default App;