Skip to content

Commit

Permalink
fix history
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Jun 24, 2024
1 parent 4bfb18d commit 93deed1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 2 additions & 4 deletions web/src/dojo/hooks/useGamesByPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -196,9 +196,7 @@ export const useGamesByPlayer = (playerIdRaw: string): GamesByPlayerInterface =>
},
averageReputation,
};

return stats;
}, [games, allTravelEncounters, allTravelEncounterResults]);
}, [games, allTravelEncounters, allTravelEncounterResults, allTradedDrugByPlayer]);

return {
games: games || [],
Expand Down
12 changes: 10 additions & 2 deletions web/src/pages/[gameId]/logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default observer(Logs);

const CustomLeftPanel = () => {
const { game, gameInfos } = useGameStore();

const { router } = useRouterContext();
return (
<VStack
flex={1}
Expand All @@ -207,7 +207,15 @@ const CustomLeftPanel = () => {
{/* <Text textStyle="subheading" textAlign="center" fontSize={["9px", "11px"]}>
{game ? reputationRanks[game.player.drugLevel as reputationRanksKeys] : ""}
</Text> */}
<Heading fontSize={["30px", "48px"]} fontWeight="400" mb={["0px", "20px"]}>
<Heading
fontSize={["30px", "48px"]}
fontWeight="400"
mb={["0px", "20px"]}
cursor="pointer"
onClick={() => {
router.push(`/game/history/${game?.gameInfos.player_id?.toString(16)}`);
}}
>
{shortString.decodeShortString(gameInfos?.player_name?.value || "")}
</Heading>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Layout
Expand Down

0 comments on commit 93deed1

Please sign in to comment.