improve months values
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user