Spaces:
Sleeping
Sleeping
File size: 2,142 Bytes
197ac2a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import { moeda } from "../format.js";
const COR = { high: "#ef4444", medium: "#f59e0b", low: "#eab308" };
const ROTULO = { high: "ALTA", medium: "MÉDIA", low: "BAIXA" };
function Detalhes({ alerta }) {
const registros = (alerta.affected_records || []).slice(0, 8);
if (!registros.length && !alerta.action_plan) return null;
return (
<details>
<summary>Ver detalhes</summary>
{registros.length > 0 && (
<ul className="recs">
{registros.map((r, i) => {
const nome = r.name || r.id || "registro";
const info = r.info ? " — " + r.info : r.amount != null ? " — " + moeda(r.amount) : "";
return (
<li key={i}>
{nome}
{info}
{r.url && (
<>
{" "}
·{" "}
<a href={r.url} target="_blank" rel="noreferrer">
abrir
</a>
</>
)}
</li>
);
})}
</ul>
)}
{alerta.action_plan && <div className="plan">{alerta.action_plan}</div>}
</details>
);
}
export default function AlertList({ alertas }) {
if (!alertas || !alertas.length) {
return <div className="empty">✅ Nenhum alerta.</div>;
}
return (
<>
{alertas.map((a, i) => {
const cor = COR[a.severity] || "#9aa3b2";
const rotulo = ROTULO[a.severity] || "INFO";
return (
<div className="alert" style={{ borderLeftColor: cor }} key={i}>
<span className="badge" style={{ background: cor }}>
{rotulo}
</span>
<span className="t">{a.title || ""}</span>
<div className="d">
{a.category || ""}
{a.description ? " — " + a.description : ""}
</div>
{a.recommended_action && (
<div className="a">
<b>Ação:</b> {a.recommended_action}
</div>
)}
<Detalhes alerta={a} />
</div>
);
})}
</>
);
}
|