diff --git a/web/src/components/icons/items/Uzi.tsx b/web/src/components/icons/items/Uzi.tsx index 6d3d8e60a..bc6572f53 100644 --- a/web/src/components/icons/items/Uzi.tsx +++ b/web/src/components/icons/items/Uzi.tsx @@ -3,7 +3,7 @@ import { Icon, IconProps } from ".."; export const Uzi = (props: IconProps) => { return ( - + ); }; diff --git a/web/src/components/layout/DrawerMenu.tsx b/web/src/components/layout/DrawerMenu.tsx index eafee7aae..1fc3a78d2 100644 --- a/web/src/components/layout/DrawerMenu.tsx +++ b/web/src/components/layout/DrawerMenu.tsx @@ -147,7 +147,7 @@ const DrawerMenu = () => { {account && ( { - router.push("/game/history"); + router.push(`/game/history/${account.address}`); }} > HISTORY diff --git a/web/src/dojo/hooks/useGamesByPlayer.tsx b/web/src/dojo/hooks/useGamesByPlayer.tsx index 3ea337b37..ffbbe6581 100644 --- a/web/src/dojo/hooks/useGamesByPlayer.tsx +++ b/web/src/dojo/hooks/useGamesByPlayer.tsx @@ -17,7 +17,7 @@ import { useTravelEncounterByPlayerQuery, useTravelEncounterResultsByPlayerQuery, } from "@/generated/graphql"; -import { useMemo } from "react"; +import { useEffect, useMemo } from "react"; import { GameClass } from "../class/Game"; import { useDojoContext } from "./useDojoContext"; import { Hustler, Hustlers } from "@/components/hustlers"; @@ -67,30 +67,35 @@ export interface GamesByPlayerInterface { playerStats?: PlayerStats; } -// TODO : change to get games by player by Season export const useGamesByPlayer = (playerId: string): GamesByPlayerInterface => { const { data, isFetched } = useGamesByPlayerQuery({ playerId, }); + const { configStore } = useDojoContext(); const { data: allSeasonSettings } = useAllSeasonSettingsQuery({}); const { data: allGameConfig } = useAllGameConfigQuery({}); - const { data: allTravelEncounters } = useTravelEncounterByPlayerQuery({ + const { data: allTravelEncounters, refetch: refetchTravelEncounters } = useTravelEncounterByPlayerQuery({ travelEncounterSelector: WorldEvents.TravelEncounter, playerId, }); - const { data: allTravelEncounterResults } = useTravelEncounterResultsByPlayerQuery({ + + const { data: allTravelEncounterResults, refetch: refetchTravelEncounterResults } = useTravelEncounterResultsByPlayerQuery({ travelEncounterResultSelector: WorldEvents.TravelEncounterResult, playerId, }); - const { data: allTradedDrugByPlayer } = useTradedDrugByPlayerQuery({ + const { data: allTradedDrugByPlayer, refetch: refetchTradedDrugs } = useTradedDrugByPlayerQuery({ tradeDrugSelector: WorldEvents.TradeDrug, playerId, }); - const { configStore } = useDojoContext(); + // useEffect(() => { + // refetchTravelEncounters() + // refetchTravelEncounterResults() + // refetchTradedDrugs() + // }, [playerId]) const games = useMemo(() => { if (!data || !allGameConfig || !allSeasonSettings) return []; @@ -198,7 +203,8 @@ export const useGamesByPlayer = (playerId: string): GamesByPlayerInterface => { }; return stats; - }, [games, allTravelEncounters, allTravelEncounterResults]); + }, [games, allTravelEncounters, allTravelEncounterResults, allTradedDrugByPlayer]); + return { games: games || [], diff --git a/web/src/pages/404.tsx b/web/src/pages/404.tsx index cad17021f..df063f137 100644 --- a/web/src/pages/404.tsx +++ b/web/src/pages/404.tsx @@ -1,3 +1,25 @@ +import { Layout, OG } from "@/components/layout"; +import { useRouterContext } from "@/dojo/hooks"; +import { Sounds, playSound } from "@/hooks/sound"; +import { Box, Flex, Text } from "@chakra-ui/react"; + export default function Custom404() { - return

404 - Page Not Found

; + const { router } = useRouterContext() + return ( + + + + { + playSound(Sounds.Magnum357) + setTimeout(() => { + playSound(Sounds.Ooo, 0.5) + }, 420) + router.push("/") + }}> + + + Are you lost hustler ? + + + ); } diff --git a/web/src/pages/[gameId]/index.tsx b/web/src/pages/[gameId]/index.tsx index cfaedeae3..f36f54fac 100644 --- a/web/src/pages/[gameId]/index.tsx +++ b/web/src/pages/[gameId]/index.tsx @@ -10,7 +10,6 @@ const Redirector = observer(() => { const { router, gameId } = useRouterContext(); const { account } = useAccount(); - const { game } = useGameStore(); useEffect(() => { @@ -19,14 +18,13 @@ const Redirector = observer(() => { if (!game) { handle = setTimeout(() => { router.push(`/`); - }, 2000); + }, 2500); } else { clearTimeout(handle); - if( game.gameInfos.game_over) { + if (game.gameInfos.game_over) { router.push(`/${gameId}/end`); - } else - if (game.player.status === PlayerStatus.Normal) { + } else if (game.player.status === PlayerStatus.Normal) { if (game.player.location) { router.push(`/${gameId}/${game.player.location.location}`); } else { diff --git a/web/src/pages/[gameId]/logs.tsx b/web/src/pages/[gameId]/logs.tsx index 82bd48ae4..b81683603 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/${gameInfos?.player_id}`); + }} + > {shortString.decodeShortString(gameInfos?.player_name?.value || "")} diff --git a/web/src/pages/game/history.tsx b/web/src/pages/game/history/[playerId].tsx similarity index 84% rename from web/src/pages/game/history.tsx rename to web/src/pages/game/history/[playerId].tsx index f482a4b76..d55645562 100644 --- a/web/src/pages/game/history.tsx +++ b/web/src/pages/game/history/[playerId].tsx @@ -20,6 +20,7 @@ import { GameClass } from "@/dojo/class/Game"; import { useDojoContext, useRouterContext } from "@/dojo/hooks"; import { PlayerStats, useGamesByPlayer } from "@/dojo/hooks/useGamesByPlayer"; import { Drugs } from "@/dojo/types"; +import { useToast } from "@/hooks/toast"; import colors from "@/theme/colors"; import { formatCashHeader } from "@/utils/ui"; @@ -53,11 +54,11 @@ import { useAccount } from "@starknet-react/core"; import { shortString } from "starknet"; export default function History() { - const { router } = useRouterContext(); - const { account } = useAccount(); + const { router, playerId } = useRouterContext(); + const { uiStore } = useDojoContext(); - const { games, onGoingGames, endedGames, playerStats } = useGamesByPlayer(account?.address || "0x0"); + const { games, onGoingGames, endedGames, playerStats } = useGamesByPlayer(playerId || "0x0"); return ( router.push("/")}>HOME} > - - - - - - - ON GOING - ENDED - - - - - - - - - - - - + + {games.length === 0 && ( + + No game played yet! - + )} + + {games.length > 0 && ( + + + + + + + ON GOING + ENDED + + + + + + + + + + + + + + + )} ); } @@ -171,9 +181,11 @@ const GameList = ({ games }: { games?: GameClass[] }) => { ); }; -const CustomLeftPanel = ({ playerStats }: { playerStats?: PlayerStats }) => { +const CustomLeftPanel = ({ playerId, playerStats }: { playerId?: string; playerStats?: PlayerStats }) => { // const { game, gameInfos } = useGameStore(); + const { toast } = useToast(); + return ( { History - + @@ -261,6 +273,20 @@ const CustomLeftPanel = ({ playerStats }: { playerStats?: PlayerStats }) => { + + ); }; @@ -388,28 +414,36 @@ export const TradedDrugsTable = ({ playerStats }: { playerStats?: PlayerStats }) - LUDES + + LUDES + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Ludes] || 0)} - SPEED + + SPEED + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Speed] || 0)} - WEED + + WEED + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Weed] || 0)} - SHROOMS + + SHROOMS + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Shrooms] || 0)} @@ -417,28 +451,36 @@ export const TradedDrugsTable = ({ playerStats }: { playerStats?: PlayerStats }) - ACID + + ACID + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Acid] || 0)} - KETAMINE + + KETAMINE + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Ketamine] || 0)} - HEROIN + + HEROIN + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Heroin] || 0)} - COCAINE + + COCAINE + {formatCashHeader(playerStats?.tradedDrugs[Drugs.Cocaine] || 0)}