From 93deed17b968da71e48fc7e3122360b431bec807 Mon Sep 17 00:00:00 2001 From: notV4l Date: Mon, 24 Jun 2024 17:04:09 +0200 Subject: [PATCH] fix history --- web/src/dojo/hooks/useGamesByPlayer.tsx | 6 ++---- web/src/pages/[gameId]/logs.tsx | 12 ++++++++++-- .../{history.tsx => history/[playerId]/index.tsx} | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) rename web/src/pages/game/{history.tsx => history/[playerId]/index.tsx} (99%) diff --git a/web/src/dojo/hooks/useGamesByPlayer.tsx b/web/src/dojo/hooks/useGamesByPlayer.tsx index d6b1009a..eeeb931e 100644 --- a/web/src/dojo/hooks/useGamesByPlayer.tsx +++ b/web/src/dojo/hooks/useGamesByPlayer.tsx @@ -163,7 +163,7 @@ export const useGamesByPlayer = (playerIdRaw: string): GamesByPlayerInterface => const averageReputation = games.map((i) => i.player.reputation).reduce((p, c) => p + c, 0) / (games.length > 0 ? games.length : 1); - const stats = { + return { totalGamesPlayed, totalGamesPaid, payRate, @@ -196,9 +196,7 @@ export const useGamesByPlayer = (playerIdRaw: string): GamesByPlayerInterface => }, averageReputation, }; - - return stats; - }, [games, allTravelEncounters, allTravelEncounterResults]); + }, [games, allTravelEncounters, allTravelEncounterResults, allTradedDrugByPlayer]); return { games: games || [], diff --git a/web/src/pages/[gameId]/logs.tsx b/web/src/pages/[gameId]/logs.tsx index 9851a5d6..c58e85c6 100644 --- a/web/src/pages/[gameId]/logs.tsx +++ b/web/src/pages/[gameId]/logs.tsx @@ -193,7 +193,7 @@ export default observer(Logs); const CustomLeftPanel = () => { const { game, gameInfos } = useGameStore(); - + const { router } = useRouterContext(); return ( { {/* {game ? reputationRanks[game.player.drugLevel as reputationRanksKeys] : ""} */} - + { + router.push(`/game/history/${game?.gameInfos.player_id?.toString(16)}`); + }} + > {shortString.decodeShortString(gameInfos?.player_name?.value || "")} diff --git a/web/src/pages/game/history.tsx b/web/src/pages/game/history/[playerId]/index.tsx similarity index 99% rename from web/src/pages/game/history.tsx rename to web/src/pages/game/history/[playerId]/index.tsx index 945c5f93..94b02b82 100644 --- a/web/src/pages/game/history.tsx +++ b/web/src/pages/game/history/[playerId]/index.tsx @@ -53,11 +53,11 @@ import { useAccount } from "@starknet-react/core"; import { shortString } from "starknet"; export default function History() { - const { router } = useRouterContext(); + const { router, playerId } = useRouterContext(); const { account } = useAccount(); const { uiStore } = useDojoContext(); - const { games, onGoingGames, endedGames, playerStats } = useGamesByPlayer(account?.address || "0x0"); + const { games, onGoingGames, endedGames, playerStats } = useGamesByPlayer(playerId || "0x0"); return (