This commit is contained in:
2026-01-03 18:19:28 +01:00
parent 2fcfc4611e
commit 12d719aa66

View File

@@ -176,29 +176,24 @@ const kpis = [
}, },
]; ];
const latestValue = data.length > 4 ? data[4].value : null; const latestValue = data.length > 4 ? data[4].value : null;
const prevValue = data.length > 3 ? data[3].value : null; const prevValue = data.length > 3 ? data[3].value : null;
const latestDate = data.length > 4 ? data[4].date : null; const latestDate = data.length > 4 ? data[4].date : null;
let trend = null; let trendValue = null;
let trendColor = null;
if (latestValue && prevValue) { if (latestValue && prevValue) {
const diff = ((latestValue - prevValue) / prevValue) * 100; trendValue = ((latestValue - prevValue) / prevValue) * 100;
trend = `${diff >= 0 ? "+" : ""}${diff.toFixed(2)}%`;
trendColor = diff >= 0 ? "#16A34A" : "#DC2626"; // vert / rouge
} }
const news = [ const news = [
{ {
type: "Forex", type: "Forex",
label: `EUR/USD: ${latestValue?.toFixed(4)}`, label: `EUR/USD: ${latestValue?.toFixed(4)}`,
trend,
color: "#1E3A8A",
date: latestDate, date: latestDate,
icon: TrendingUp, icon: TrendingUp,
trendColor, trendValue, // <- même logique que KPIs
}, },
// { // {
// type: "Logistic", // type: "Logistic",
@@ -550,12 +545,19 @@ export default function App() {
</div> </div>
<div className="ml-6"> <div className="ml-6">
<span style={{ color: n.color }}>{n.label}</span> <span style={{ color: n.color }}>{n.label}</span>
{n.trend && ( {n.trendValue !== null && (
<span <span
className="ml-2 font-semibold" className={`
style={{ color: n.trendColor }} ml-2 px-2 py-0.5 text-xs font-semibold rounded-md border
${
n.trendValue >= 0
? "bg-green-50 text-green-700 border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800"
: "bg-red-50 text-red-700 border-red-200 dark:bg-red-900/30 dark:text-red-400 dark:border-red-800"
}
`}
> >
{n.trend} {n.trendValue >= 0 ? "+" : ""}
{n.trendValue.toFixed(2)}%
</span> </span>
)} )}
</div> </div>