import { useState } from "react"; import { ChevronDown, ChevronUp, AlertTriangle, BookOpen, ShieldCheck, Pill, RefreshCcw, FlaskConical, CheckCircle2, Camera, } from "lucide-react"; import { RiskBadge } from "@/components/risk-badge"; type Props = { imageUrl: string; confidence: number; // contoh: 0.95 diseaseName: string; scientificName: string; riskLevel: string; description: string; symptoms: string[]; preventions: string[]; medicines: string[]; onRescan?: () => void; }; export function DiagnosisResultView({ imageUrl, confidence, diseaseName, scientificName, riskLevel, description, symptoms, preventions, medicines, onRescan, }: Props) { const [openSection, setOpenSection] = useState("detail"); const getRiskLevelKey = (level: string): "low" | "medium" | "high" => { const normalized = level.toLowerCase(); if (normalized.includes("rendah")) return "low"; if (normalized.includes("tinggi")) return "high"; return "medium"; }; const toggleSection = (section: string) => { setOpenSection(openSection === section ? "" : section); }; const confidencePercent = Math.round(confidence * 100); return (
{/* Image Area & Result */}
Daun yang dianalisis
Gambar yang dianalisis
{/* Result Card */}
HASIL DETEKSI ML

{diseaseName}

{scientificName}

{/* Confidence Bar */}
Tingkat Keyakinan AI {confidencePercent}%

Di atas ambang batas minimum (75%)

Tingkat Keparahan:
{/* Education & References */}
{/* Rescan Button */} {onRescan && (
)} {/* Detail Section */}
toggleSection("detail")} className="flex items-center justify-between p-4 cursor-pointer hover:bg-slate-50" >
Detail Penyakit
{openSection === "detail" ? ( ) : ( )}
{openSection === "detail" && (

{description}

Gejala Umum:
    {symptoms.map((sym, i) => (
  • {sym}
  • ))}
)}
{/* Prevention Section */}
toggleSection("cegah")} className="flex items-center justify-between p-4 cursor-pointer hover:bg-slate-50" >
Panduan Pencegahan
{openSection === "cegah" ? ( ) : ( )}
{openSection === "cegah" && (
    {preventions.map((prev, i) => (
  • {" "} {prev}
  • ))}
)}
{/* Medicine Section */}
toggleSection("obat")} className="flex items-center justify-between p-4 cursor-pointer hover:bg-slate-50" >
Rekomendasi Obat
{openSection === "obat" ? ( ) : ( )}
{openSection === "obat" && (
    {medicines.map((med, i) => (
  • {" "} {med}
  • ))}
)}
{/* Disclaimer */}
Disclaimer Penting

ZeaVis Edu adalah alat bantu edukasi awal, bukan pengganti diagnosis profesional. Hasil ini tidak dapat dijadikan dasar keputusan agronomis tanpa konfirmasi dari{" "} ahli pertanian atau Petugas Pengamat Organisme Pengganggu Tanaman (POPT) {" "} yang berwenang.

); }