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">
{county.name}
</h1>
<table className="text-left">
<thead>
<tr className="border-b border-ctp-surface2 text-ctp-subtext1">
<th className="p-2">Player</th>
<th className="p-2">Rank</th>
</tr>
</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>
{county?.players.length > 0 ? (
<table className="text-left">
<thead>
<tr className="border-b border-ctp-surface2 text-ctp-subtext1">
<th className="p-2">Player</th>
<th className="p-2">Rank</th>
</tr>
))}
</tbody>
</table>
</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>
))}
</tbody>
</table>
) : (
<p className="text-center">no players here yet :(</p>
)}
</li>
))}
</ul>