fix: history on end game
This commit is contained in:
parent
14b53886cd
commit
67a4096442
@ -56,7 +56,7 @@ export function Game() {
|
||||
New Game
|
||||
</button>
|
||||
</GameBoard>
|
||||
<GameHistory />
|
||||
<GameHistory plays={lastGame.game.plays} />
|
||||
</>
|
||||
}
|
||||
|
||||
@ -187,10 +187,10 @@ function WinnerText({ me, result }: { me: PlayResult, result: PlayResult }) {
|
||||
</div>
|
||||
}
|
||||
|
||||
function GameHistory() {
|
||||
function GameHistory({ plays }: { plays?: Play[] }) {
|
||||
const session = useSession();
|
||||
|
||||
if (!session.currentGame || session.currentGame.plays.length === 0) {
|
||||
if ((!session.currentGame || session.currentGame.plays.length === 0) && plays === undefined) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ function GameHistory() {
|
||||
Game History
|
||||
</h2>
|
||||
<div>
|
||||
{session.currentGame.plays.map((play, i) => <div key={i} className="p-2">
|
||||
{(plays ?? session.currentGame!.plays).map((play, i) => <div key={i} className="p-2">
|
||||
User played <span className="text-blue-500">{play.user}</span>, and CPU played <span className="text-red-500">{play.cpu}</span>! Winner:{" "}
|
||||
<span className={
|
||||
play.winner === 'tie' ? 'text-yellow-500' :
|
||||
|
Loading…
Reference in New Issue
Block a user