-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add game route without any additional features
- Loading branch information
Showing
6 changed files
with
83 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Helmet } from "react-helmet-async" | ||
import type { LoaderFunction } from "react-router" | ||
import { json, useLoaderData } from "react-router-dom" | ||
import { Game as GameEntity } from "./entities" | ||
import GameService from "./services/games.service" | ||
|
||
export const loader: LoaderFunction = async ({ | ||
params, | ||
}): Promise<GameEntity> => { | ||
let gs = new GameService() | ||
|
||
let gameId = parseInt(params.gameId as string, 10) | ||
|
||
if (!Number.isNaN(gameId)) { | ||
let game = await gs.get(gameId) | ||
|
||
if (game !== undefined) return game | ||
throw json({ message: "game id not found", status: 404 }) | ||
} | ||
throw json({ message: "internal api error", status: 500 }) | ||
} | ||
|
||
export function Game() { | ||
let game = useLoaderData() as GameEntity | ||
|
||
return ( | ||
<> | ||
<Helmet> | ||
<title>{`Game ${game.id} - Hitster`}</title> | ||
</Helmet> | ||
<p>Game ID: {game.id}</p> | ||
</> | ||
) | ||
} |
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
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