03.01.26
This commit is contained in:
34
src/App.jsx
34
src/App.jsx
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user