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; 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") || normalized === "low") return "low"; if (normalized.includes("tinggi") || normalized === "high") 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 = 75 ? "text-emerald-600" : "text-amber-500" } > {confidencePercent}%
= 75 ? "bg-emerald-500" : "bg-amber-500" }`} style={{ width: `${confidencePercent}%` }} >
{confidencePercent >= 75 ? (

Di atas ambang batas minimum (75%)

) : (

Di bawah 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.

); }