-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien MAIRE
authored and
Julien MAIRE
committed
Feb 3, 2025
1 parent
5f61146
commit 8163419
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Typography from "@mui/material/Typography/Typography"; | ||
import { Show, SimpleShowLayout, TextField, useFieldValue } from "react-admin"; | ||
import GameGrid from "../boardView/GameGrid"; | ||
import { tokenColors } from "../boardView/model/consts"; | ||
|
||
const MatchupField = () => { | ||
const p1 = useFieldValue({ source: "first_player" }); | ||
const p2 = useFieldValue({ source: "second_player" }); | ||
return ( | ||
<Typography variant="h6" sx={{ textAlign: "center" }}> | ||
<span className={tokenColors[1]}>{p1}</span> <b>vs</b>{" "} | ||
<span className={tokenColors[2]}>{p2}</span> | ||
</Typography> | ||
); | ||
}; | ||
|
||
const GameStatusField = () => { | ||
const gameStatus = useFieldValue({ source: "_game_status" }); | ||
return ( | ||
<Typography sx={{ textAlign: "center" }}> | ||
The match status is: <b>{gameStatus}</b>. | ||
</Typography> | ||
); | ||
}; | ||
|
||
const GameBoardView = () => { | ||
const victoryState = useFieldValue({ source: "_victory_state" }); | ||
const boardState = useFieldValue({ source: "board_state" }); | ||
console.log(victoryState, boardState); | ||
if (!victoryState || !boardState) { | ||
return ""; | ||
} | ||
return <GameGrid victoryState={victoryState} boardState={boardState} />; | ||
}; | ||
|
||
export const GameShow = () => ( | ||
<Show> | ||
<SimpleShowLayout> | ||
<MatchupField /> | ||
<GameStatusField /> | ||
<GameBoardView /> | ||
<TextField source="creation_date" /> | ||
</SimpleShowLayout> | ||
</Show> | ||
); |