import { useState } from "react"; import ReactMarkdown from "react-markdown"; import { CheckCircle2Icon, XCircleIcon, AlertTriangleIcon, ChevronDownIcon, ChevronUpIcon, InfoIcon, EditIcon, CheckIcon, } from "lucide-react"; import type { ComplianceRow, ViolationCard, AnalysisSummary } from "../App"; const CATEGORIES = ["SUPLEMEN", "DAIRY", "DAGING_OLAHAN", "BUAH_SAYUR"]; interface Step2Props { rows: ComplianceRow[]; violationCards: ViolationCard[]; summary: AnalysisSummary; category: string; narration: string; onNarrationChange: (val: string) => void; onCategoryChange: (cat: string) => void; onApprove: () => void; } export function Step2Review({ rows, violationCards, summary, category, narration, onNarrationChange, onCategoryChange, onApprove, }: Step2Props) { const [selectedCategory, setSelectedCategory] = useState(category); const [editingCategory, setEditingCategory] = useState(false); const [expandedViolations, setExpandedViolations] = useState>( new Set(violationCards.length > 0 ? [violationCards[0].id] : []) ); const [reviewed, setReviewed] = useState(false); const [previewMode, setPreviewMode] = useState(true); const toggleViolation = (id: string) => { setExpandedViolations((prev) => { const next = new Set(prev); if (next.has(id)) next.delete(id); else next.add(id); return next; }); }; const handleCategoryConfirm = () => { setEditingCategory(false); onCategoryChange(selectedCategory); }; const severityColors = { high: "bg-red-50 border-red-200 text-red-700", medium: "bg-amber-50 border-amber-200 text-amber-700", low: "bg-blue-50 border-blue-200 text-blue-600", }; const severityLabels = { high: "Kritikal", medium: "Sedang", low: "Perlu Data", }; const markdownComponents = { h1: ({node, ...props}: any) =>

, h2: ({node, ...props}: any) =>

, h3: ({node, ...props}: any) =>

, p: ({node, ...props}: any) =>

, strong: ({node, ...props}: any) => , ul: ({node, ...props}: any) =>