import { useState } from "react"; import { ClipboardList, Loader, AlertTriangle } from "lucide-react"; import { submitOfficerNotes } from "../api/client.js"; const QUICK_FILLS = [ { label: "Factory at 40% capacity", text: "Factory operating at 40% capacity.", mode: "set" }, { label: "MD evasive about order book", text: " MD was evasive about the order book.", mode: "append" }, { label: "Inventory appears rusted", text: " Inventory appears aged and rusted.", mode: "append" }, { label: "Strong order book — 3 LOIs from Tata", text: " Strong order book with 3 Letters of Intent from Tata Steel.", mode: "append" }, { label: "Books well maintained, MD cooperative", text: " Books well maintained. MD was cooperative and transparent.", mode: "append" }, ]; function scoreColor(score) { if (score >= 75) return "var(--success)"; if (score >= 55) return "var(--warning)"; return "var(--danger)"; } function decisionColor(decision) { if (decision === "APPROVE") return "var(--success)"; if (decision === "CONDITIONAL") return "var(--warning)"; return "var(--danger)"; } export default function OfficerNotesPanel({ jobId, currentScore, currentDecision, onScoreUpdate }) { const [notes, setNotes] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const [lastResult, setLastResult] = useState(null); const charCount = notes.length; const charColor = charCount >= 2000 ? "var(--danger)" : charCount >= 1800 ? "var(--warning)" : "var(--text-muted)"; async function handleSubmit() { if (!notes.trim()) return; setIsSubmitting(true); try { const response = await submitOfficerNotes(jobId, notes); setLastResult(response); if (!response.injection_detected) { onScoreUpdate(response.score_after, response.decision_after, response.score_delta); } } catch (err) { console.error("Officer notes submission failed:", err); } finally { setIsSubmitting(false); } } function applyQuickFill(chip) { if (chip.mode === "set") setNotes(chip.text); else setNotes((prev) => prev + chip.text); setLastResult(null); } return (
Primary Due Diligence Integration — Field visit observations adjust the AI risk score