improve months values

This commit is contained in:
Romulus21
2024-03-09 16:19:10 +01:00
parent a0ed432d2b
commit dc9351dd9a
6 changed files with 312 additions and 739 deletions

View File

@@ -38,11 +38,22 @@ const YearRainfall = () => {
<h1 className="-mx-2 -mt-1 bg-blue-500 px-2 py-1 text-center text-lg font-bold text-white">Précipitations des derniers mois</h1>
{errorLabel()}
<table className="w-full text-center">
<thead>
<tr>
<th>Mois</th>
<th>{(new Date).getFullYear()}</th>
<th>{(new Date).getFullYear() - 1}</th>
</tr>
</thead>
<tbody>
{data.map(line => <tr key={line.year + '-' + line.month} className="">
<td>{line.label}</td>
<td className="px-2 text-right">{line.values}</td>
</tr>)}
{Object.entries(data)
.map(([month, months]) => {
return <tr key={month}>
<td>{month}</td>
<td>{months.find(m => m.year === (new Date).getFullYear() && m.month === Number(month))?.values}</td>
<td>{months.find(m => m.year === ((new Date).getFullYear() - 1) && m.month === Number(month))?.values}</td>
</tr>
})}
</tbody>
</table>
</Card>