Skip to content

Commit

Permalink
Sort player sheet tabs by creation order (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrod-lowe authored Sep 24, 2024
1 parent f99bb3a commit 2d208df
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/src/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ const GameContent: React.FC<{ id: string, userEmail: string }> = ({ id, userEmai
<div className="game-container">
<TopBar title={game.gameName} userEmail={ userEmail } />
<div className="tab-bar">
{game.playerSheets.map((sheet) => (
{game.playerSheets
.slice() // Create a copy of the array to avoid mutating state
.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()) // Sort by createdAt
.map((sheet) => (
<button
key={sheet.userId}
className={activeSheet === sheet.userId ? 'active' : ''}
Expand Down

0 comments on commit 2d208df

Please sign in to comment.