Added gameId to Game path
This commit is contained in:
parent
35334f0308
commit
f0a701a2fd
@ -15,7 +15,7 @@ const AppRoutes = [
|
||||
element: <Counter/>
|
||||
},
|
||||
{
|
||||
path: "/game",
|
||||
path: "/game/:id",
|
||||
element: <Game/>,
|
||||
},
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ const LobbyPage: FC = () => { // TODO check if player is defined in storage, if
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.debug("Game created: ", data);
|
||||
// TODO redirect to game page
|
||||
navigate("/game/" + data.id)
|
||||
} else {
|
||||
const data = await response.text();
|
||||
console.error("Error: ", data);
|
||||
@ -51,6 +51,7 @@ const GameTable: FC<ComponentProps> = ({className}) => {
|
||||
|
||||
const data = useAtomValue(fetchAtom);
|
||||
const thisPlayer = useAtomValue(thisPlayerAtom);
|
||||
const navigate = useNavigate();
|
||||
|
||||
async function joinGame(gameId: string): Promise<void> {
|
||||
if (thisPlayer === undefined) throw new Error("Player is undefined");
|
||||
@ -60,10 +61,10 @@ const GameTable: FC<ComponentProps> = ({className}) => {
|
||||
const result = await postData("/game/join/" + gameId, {body: thisPlayer});
|
||||
|
||||
if (result.ok) {
|
||||
console.debug("Joined game " + gameId, await result.json());
|
||||
// TODO redirect to game page
|
||||
console.debug("Joined game " + gameId, await result.text());
|
||||
navigate("/game/" + gameId);
|
||||
} else {
|
||||
console.error("Failed to join game " + gameId, await result.json());
|
||||
console.error("Failed to join game " + gameId, await result.text());
|
||||
// TODO show error message
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace pacMan.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class GameController : GenericController // TODO reconnect using player id
|
||||
public class GameController : GenericController
|
||||
{
|
||||
private readonly IActionService _actionService;
|
||||
private readonly GameService _gameService;
|
||||
|
Loading…
x
Reference in New Issue
Block a user