import React from 'react'; import { saveAs } from 'file-saver'; // ... (in handleDownload) import { motion } from 'framer-motion'; const Results = ({ result, onReset }) => { if (!result) return null; // Mock score: 0 = Human, 100 = AI const score = result.score || 0; const isAI = score > 50; const handleDownload = async () => { try { // Need to pass the original text here. // Since result doesn't contain the original text by default (optimized away), // we should ideally have it. // For now, let's assume `result.text` is available or we pass input props. // Wait, result only has score/label/ppl. // We need to pass the text from App.jsx or store it in result. // Let's assume App.jsx will now pass text in `result` (Need to update App.jsx too if not present) // Actually, simpler: Let's assume we pass `text` as a prop to Results component for now? // Or update backend to echo back the text? // Let's update App.jsx to attach `originalText` to the result object. const response = await fetch('/api/report/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: result.originalText || "Content not available", score: score, label: isAI ? "AI Generated" : "Human Written" }) }); if (!response.ok) throw new Error("Report generation failed"); const blob = await response.blob(); saveAs(blob, "DetectAI_Report.pdf"); } catch (e) { alert("Failed to download report: " + e.message); } }; return (

Detection Result

{/* Gauge Body */}
{/* Gauge Fill */}
{score.toFixed(1)}% {isAI ? 'AI GENERATED' : 'HUMAN WRITTEN'}

Our DeBERTa model is {score.toFixed(1)}% confident that this content was {isAI ? 'generated by AI' : 'written by a human'}.

); }; export default Results;