render players conditionally

This commit is contained in:
Joonas 2023-01-18 22:00:16 +02:00
parent 4fc8a4036d
commit bb2ab1014e
1 changed files with 22 additions and 18 deletions

View File

@ -181,25 +181,29 @@ export default function Index() {
<h1 className="text-center text-4xl tracking-tighter text-ctp-subtext0"> <h1 className="text-center text-4xl tracking-tighter text-ctp-subtext0">
{county.name} {county.name}
</h1> </h1>
<table className="text-left"> {county?.players.length > 0 ? (
<thead> <table className="text-left">
<tr className="border-b border-ctp-surface2 text-ctp-subtext1"> <thead>
<th className="p-2">Player</th> <tr className="border-b border-ctp-surface2 text-ctp-subtext1">
<th className="p-2">Rank</th> <th className="p-2">Player</th>
</tr> <th className="p-2">Rank</th>
</thead>
<tbody>
{county.players.map((player) => (
<tr
key={player.id}
className="border-b border-ctp-surface2 odd:bg-ctp-surface0 even:bg-ctp-surface1"
>
<td className="p-2">{player.playerName}</td>
<td className="p-2">#{player.rank}</td>
</tr> </tr>
))} </thead>
</tbody> <tbody>
</table> {county.players.map((player) => (
<tr
key={player.id}
className="border-b border-ctp-surface2 odd:bg-ctp-surface0 even:bg-ctp-surface1"
>
<td className="p-2">{player.playerName}</td>
<td className="p-2">#{player.rank}</td>
</tr>
))}
</tbody>
</table>
) : (
<p className="text-center">no players here yet :(</p>
)}
</li> </li>
))} ))}
</ul> </ul>