I'm trying to make a "weekly planning" in reactJS, i'm a beginner, so sorry if you see any mistakes.
I have an array of events, like this :
var events = [
{
date : moment("14-03-2022", "DD-MM-YYYY").format("ddd D MMM YYYY"),
name : "EVENT MONDAY 13 2022"
},
{
date : moment("16-03-2022", "DD-MM-YYYY").format("ddd D MMM YYYY"),
name : "EVENT WEDNESDAY 2022"
}];
I created a condition to see if the event date is the same of the week date and i put this in a table like this :
<table className="table table-bordered text-center">
<thead>
<tr className="bg-light-gray">
{week.map((wk) => (<th class="text-uppercase">{wk}</th>))}
</tr>
</thead>
<tbody>
<tr>
{week.map((wk) => (
events.map((ev) =>(
wk === ev.date ?
<td>{ev.name}</td>
:
<td></td>
))
))}
</tr>
</tbody>
</table>
But it doesn't work because it creates too much of "td" elements, and i don't know how to put the event name below the correct date...
Can someone help me there?