// helpers.jsx — shared lookups and small components // Loaded BEFORE the dashboard/app const OUTCOME_LABELS = { required: "Required", borderline: "Borderline", info_needed: "Info needed", not_required: "Not required", excluded: "Screened out", }; const OUTCOME_ORDER = ["required", "borderline", "info_needed", "not_required", "excluded"]; const CONF_LABELS = { high: "High", medium: "Medium", low: "Low" }; const CONF_PIPS = { high: 3, medium: 2, low: 1 }; function Badge({ outcome, children }) { return ( {children || OUTCOME_LABELS[outcome]} ); } function ConfBar({ confidence }) { const n = CONF_PIPS[confidence] || 0; return ( {[0, 1, 2].map((i) => ( ))} ); } function FlagSet({ rec }) { const flags = []; if (rec.outcome === "required" || rec.outcome === "borderline" || rec.outcome === "info_needed") { flags.push({ cls: "attn", label: "!", title: "Needs attention" }); } if (rec.overridden) flags.push({ cls: "over", label: "✎", title: "Lawyer override" }); if (rec.approved) flags.push({ cls: "ok", label: "✓", title: "Partner-approved" }); if (!flags.length) return null; return ( {flags.map((f, i) => ( {f.label} ))} ); } function needsAttention(r) { return ["required", "borderline", "info_needed"].includes(r.outcome) && !r.approved; } function effectiveOutcome(r) { return r.lawyerOutcome || r.outcome; } function regionLabel(id, regions) { return regions.find((r) => r.id === id)?.short || id; } window.MC_HELPERS = { OUTCOME_LABELS, OUTCOME_ORDER, CONF_LABELS, CONF_PIPS, Badge, ConfBar, FlagSet, needsAttention, effectiveOutcome, regionLabel, };