-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
33 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 |
---|---|---|
@@ -1,48 +1,38 @@ | ||
'use client'; | ||
|
||
import { useWallet } from '@solana/wallet-adapter-react'; | ||
import { WalletButton } from '../solana/solana-provider'; | ||
import { AppHero, ellipsify } from '../ui/ui-layout'; | ||
import { ExplorerLink } from '../cluster/cluster-ui'; | ||
import { useSquaresProgram, useAllGames } from './squares-data-access'; | ||
import { useAllGames } from './squares-data-access'; | ||
import { SquaresCreate } from './squares-ui'; | ||
import { WalletButton } from '../solana/solana-provider'; | ||
|
||
export default function SquaresListFeature() { | ||
const { publicKey } = useWallet(); | ||
const { connected } = useWallet(); | ||
const gamesData = useAllGames(); | ||
|
||
console.log("Games data:", gamesData.games.data); | ||
|
||
return ( | ||
<div> | ||
{publicKey ? ( | ||
<> | ||
<AppHero | ||
title="Squares" | ||
subtitle={ | ||
'You can create a new game of Squares by clicking the "Create" button. The state of the game is stored on-chain.' | ||
} | ||
> | ||
<SquaresCreate /> | ||
</AppHero> | ||
<div className="games-list"> | ||
{gamesData?.games?.data?.map((game) => ( | ||
<div key={game.publicKey.toBase58()} className="game-item"> | ||
<ExplorerLink path={game.publicKey.toBase58()} label={game.publicKey.toBase58()} /> | ||
<AppHero | ||
title="Squares" | ||
subtitle={ | ||
'View all available games or create a new one.' | ||
} | ||
> | ||
{connected ? <SquaresCreate /> : <WalletButton />} | ||
</AppHero> | ||
<div className="games-list flex flex-wrap justify-center"> | ||
{gamesData?.games?.data?.map((game) => ( | ||
<div key={game.publicKey.toBase58()} className="w-full md:w-1/2 lg:w-1/3 p-4"> | ||
<a href={`/games/${game.publicKey.toBase58()}`} className="block"> | ||
<div className="border rounded-lg p-4 hover:shadow-lg transition-shadow"> | ||
<h2 className="text-xl font-semibold mb-2">Game #{game.publicKey.toBase58().slice(0, 8)}</h2> | ||
<ExplorerLink path={`address/${game.publicKey.toBase58()}`} label={ellipsify(game.publicKey.toBase58())} /> | ||
</div> | ||
))} | ||
</a> | ||
</div> | ||
</> | ||
) : ( | ||
<AppHero | ||
title="Squares" | ||
subtitle={ | ||
'You can create a new game of Squares after you select your wallet. The state of the game is stored on-chain.' | ||
} | ||
> | ||
<WalletButton /> | ||
</AppHero> | ||
)} | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
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