Skip to content

Commit

Permalink
nit: frontend error path clean
Browse files Browse the repository at this point in the history
  • Loading branch information
rsproule committed Jan 3, 2024
1 parent 2ec72a1 commit f37a3fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions frontend/src/app/game/[gameId]/GamePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { EventStream } from "@/src/components/tankGame/EventsStream";
import { TankGame } from "@/src/components/tankGame/TankGame";
import { Button } from "@/src/components/ui/button";
import { Toaster } from "@/src/components/ui/toaster";
import { gameViewAddress, useGameViewGetSettings } from "@/src/generated";
import Link from "next/link";
Expand Down Expand Up @@ -45,8 +46,11 @@ export function GamePage({ gameAddress }: { gameAddress: `0x${string}` }) {
}}
>
Game not found at address: {gameAddress}
<br />
<Link href="/games">Back to Games</Link>
<div>
<Link href="/games">
<Button>Back to Games</Button>
</Link>
</div>
</div>
);
}
8 changes: 6 additions & 2 deletions frontend/src/app/games/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useTankGamePlayersCount,
} from "@/src/generated";
import { useEffect, useState } from "react";
import { Address, useBalance, useBlockNumber, useNetwork } from "wagmi";
import { Address, useAccount, useBalance, useBlockNumber, useNetwork } from "wagmi";
import { getPublicClient } from "wagmi/actions";
import CreateGameForm from "@/src/components/CreateGameForm";
import {
Expand All @@ -26,6 +26,7 @@ import { Button } from "@/src/components/ui/button";

export default function GamesList() {
const { data: blockNumber } = useBlockNumber({ watch: true });
const { address } = useAccount();
const [games, setGames] = useState();
const { chain } = useNetwork();
const getLogs = async () => {
Expand All @@ -51,7 +52,10 @@ export default function GamesList() {
})
.catch(console.error);
}, [blockNumber]);
console.log({ games });

if (!address) {
return <div>Connect your wallet to see games.</div>;
}
return (
<div className="container pb-20">
<Accordion type="single" collapsible>
Expand Down

0 comments on commit f37a3fb

Please sign in to comment.