From d82111db686d509ae0ae2344038cc36c87c8ecc9 Mon Sep 17 00:00:00 2001 From: izaakwalz Date: Mon, 8 Jul 2024 03:24:16 +0100 Subject: [PATCH 1/3] fix: game property data not showing up --- .../home/_components/game-mode.tsx | 43 ++++++++++--------- .../home/_components/live-game-container.tsx | 9 ++-- .../home/_components/success-failure.tsx | 4 +- src/app/(dashboard)/home/page.tsx | 3 ++ src/app/(dashboard)/leaderboard/page.tsx | 6 +-- src/app/(dashboard)/marketplace/page.tsx | 9 ++-- src/app/(dashboard)/tasks/page.tsx | 4 +- src/app/(page)/page.tsx | 8 ++-- src/app/gameplay/_components/success.tsx | 4 +- src/components/cards/card.tsx | 4 +- src/components/layouts/connect-wallet.tsx | 2 +- src/components/layouts/site-header.tsx | 2 +- src/components/shell.tsx | 2 +- src/components/ui/alert-dialog.tsx | 2 +- src/components/ui/extension-carousel.tsx | 8 ++-- src/components/ui/sheet.tsx | 2 +- src/components/ui/toast.tsx | 2 +- src/lib/extrinsic.ts | 7 +-- src/types/index.ts | 10 ++--- 19 files changed, 70 insertions(+), 61 deletions(-) diff --git a/src/app/(dashboard)/home/_components/game-mode.tsx b/src/app/(dashboard)/home/_components/game-mode.tsx index 7d80228..2e2241d 100644 --- a/src/app/(dashboard)/home/_components/game-mode.tsx +++ b/src/app/(dashboard)/home/_components/game-mode.tsx @@ -29,13 +29,15 @@ import { useSubstrateContext } from '@/context/polkadot-contex'; import { getNextGameID } from '@/lib/queries'; import { submitGameAnswer } from '@/lib/extrinsic'; import Form, { useZodForm } from '@/components/ui/form'; +import { GameData } from '@/types'; interface GameProps { + data: GameData; setDisplay: Dispatch>; close: () => void; } -export default function GameMode({ setDisplay, close }: GameProps) { +export default function GameMode({ data, setDisplay, close }: GameProps) { // const [isPending, startTransition] = useTransition(); const [isLoading, setIsLoading] = useState(false); const [gameId, setGameID] = useState(); @@ -109,8 +111,9 @@ export default function GameMode({ setDisplay, close }: GameProps) { {Array.from({ length: 5 }).map((_, index) => ( - {Array.from({ length: 5 }).map((_, index) => ( + {data.images.map((image, index) => ( ))} - ( */} + + {/* ))} */} + {/* + /> */} @@ -150,22 +156,19 @@ export default function GameMode({ setDisplay, close }: GameProps) {

Property 1

- +

One bed luxury apartment,

- - + +
- - - + + {/* + */}
-

Key features

-

- Private balcony. Communal roof terrace. Residents concierge service. Close - proximity to green spaces. 999 year lease with peppercorn ground rent -

+

Summary

+

{data.summary}

@@ -196,7 +199,7 @@ export default function GameMode({ setDisplay, close }: GameProps) { interface DescriptionProps extends React.HTMLAttributes { title: string; - description?: string; + description?: any; } const DescriptionList = ({ className, title, description }: DescriptionProps) => { diff --git a/src/app/(dashboard)/home/_components/live-game-container.tsx b/src/app/(dashboard)/home/_components/live-game-container.tsx index a45855b..d60ec9c 100644 --- a/src/app/(dashboard)/home/_components/live-game-container.tsx +++ b/src/app/(dashboard)/home/_components/live-game-container.tsx @@ -28,7 +28,7 @@ type GameType = 0 | 1; export default function LiveGamePlay({ type }: { type: GameType }) { const [openGameSheet, setOpenGameSheet] = useState(false); - const [propertyDisplay, setPropertyDisplay] = useState(null); + const [propertyDisplay, setPropertyDisplay] = useState(); const [display, setDisplay] = useState<'start' | 'play' | 'success' | 'fail'>('start'); function closeGameSheet() { @@ -44,7 +44,7 @@ export default function LiveGamePlay({ type }: { type: GameType }) { setPropertyDisplay={setPropertyDisplay} /> ), - play: , + play: , success: , fail: }; @@ -91,10 +91,11 @@ function StartGame({ type, close, setDisplay, setPropertyDisplay }: GameProps) { async function onPlay() { try { setIsLoading(true); - await playGame(type, address, data => { - setPropertyDisplay(data); + await playGame(type, address, async data => { + setPropertyDisplay(await data); setDisplay('play'); }); + setIsLoading(false); } catch (error) { console.log(error); diff --git a/src/app/(dashboard)/home/_components/success-failure.tsx b/src/app/(dashboard)/home/_components/success-failure.tsx index 95f5397..40086cc 100644 --- a/src/app/(dashboard)/home/_components/success-failure.tsx +++ b/src/app/(dashboard)/home/_components/success-failure.tsx @@ -13,7 +13,7 @@ export function GuessPass({ close }: GameProps) { 1500
-
+
1500
-
+
diff --git a/src/app/(dashboard)/home/page.tsx b/src/app/(dashboard)/home/page.tsx index ce0f8e2..1c3ad49 100644 --- a/src/app/(dashboard)/home/page.tsx +++ b/src/app/(dashboard)/home/page.tsx @@ -14,6 +14,7 @@ import { getLeadBoards, getUserData } from '@/lib/queries'; import ProfileHeader from './_components/profile-header'; import { useSubstrateContext } from '@/context/polkadot-contex'; import { useCallback, useEffect, useState } from 'react'; +import { fetchPropertyData } from '@/app/actions'; // type Player = { // Player: 1; @@ -32,6 +33,8 @@ export default function App() { async function fetchData(address: string) { const boardList = await getLeadBoards(); + // const property = await fetchPropertyData(139361966) + // console.log(property) const userData = await getUserData(address); if (userData !== null && boardList !== null) { diff --git a/src/app/(dashboard)/leaderboard/page.tsx b/src/app/(dashboard)/leaderboard/page.tsx index 7177580..ba707f6 100644 --- a/src/app/(dashboard)/leaderboard/page.tsx +++ b/src/app/(dashboard)/leaderboard/page.tsx @@ -21,7 +21,7 @@ export function LeaderBoardCard({ points, winner }: LeaderProps) { 01 )}
- Rounded avatar + Rounded avatar Victor X
@@ -51,13 +51,13 @@ async function ChampionCard() { ); } -export default async function Page() { +export default function Page() { return (
Rounded avatar diff --git a/src/app/(dashboard)/marketplace/page.tsx b/src/app/(dashboard)/marketplace/page.tsx index 7dfc631..4313b0a 100644 --- a/src/app/(dashboard)/marketplace/page.tsx +++ b/src/app/(dashboard)/marketplace/page.tsx @@ -4,6 +4,7 @@ import { Shell } from '@/components/shell'; import { Button } from '@/components/ui/button'; import { siteConfig } from '@/config/site'; import Image from 'next/image'; +import Link from 'next/link'; const collections = ['All', 'Blue', 'Red', 'Pink', 'Orange', 'Purple', 'Teal', 'Coral']; @@ -20,7 +21,7 @@ export default function Page({ return ( -
+
{data.map((nft: any) => ( - {collection} + {collection} ); })} @@ -61,7 +62,7 @@ export default function Page({

Listings

-
+
{siteConfig.nfts.map((nft: any) => (
- + @@ -85,7 +85,7 @@ export default function Tasks() { export const TaskCard = ({ type, title, description }: TaskCardProps) => { return ( -
+
{' '} {title} diff --git a/src/app/(page)/page.tsx b/src/app/(page)/page.tsx index b803e3c..5ff875f 100644 --- a/src/app/(page)/page.tsx +++ b/src/app/(page)/page.tsx @@ -36,7 +36,7 @@ export default function Home() {
-
+
@@ -44,7 +44,7 @@ export default function Home() {

win valuable NFTs

-
+
@@ -52,7 +52,7 @@ export default function Home() {

win valuable NFTs

-
+
@@ -60,7 +60,7 @@ export default function Home() {

win valuable NFTs

-
+
diff --git a/src/app/gameplay/_components/success.tsx b/src/app/gameplay/_components/success.tsx index 5b751f7..344c54c 100644 --- a/src/app/gameplay/_components/success.tsx +++ b/src/app/gameplay/_components/success.tsx @@ -9,7 +9,7 @@ export function SuccessRedirect() {

Points : {points}

-
+
@@ -33,7 +33,7 @@ export function FailRedirect() { Points : {points}x -
+

Sorry wrong guess

You have lost -10 points

diff --git a/src/components/cards/card.tsx b/src/components/cards/card.tsx index 1e318eb..c73918c 100644 --- a/src/components/cards/card.tsx +++ b/src/components/cards/card.tsx @@ -9,7 +9,7 @@ export function Card({ className, title, description, children, ...props }: Card return (
- ); @@ -362,7 +362,7 @@ const CarouselNext = forwardRef - + Next slide ); diff --git a/src/components/ui/sheet.tsx b/src/components/ui/sheet.tsx index e1f1fa0..205e7c8 100644 --- a/src/components/ui/sheet.tsx +++ b/src/components/ui/sheet.tsx @@ -31,7 +31,7 @@ const SheetOverlay = React.forwardRef< SheetOverlay.displayName = SheetPrimitive.Overlay.displayName; const sheetVariants = cva( - 'fixed z-50 gap-4 bg-background p-6 transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500', + 'fixed z-50 gap-4 bg-background p-6 transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out', { variants: { side: { diff --git a/src/components/ui/toast.tsx b/src/components/ui/toast.tsx index 12b09ab..cccb43e 100644 --- a/src/components/ui/toast.tsx +++ b/src/components/ui/toast.tsx @@ -83,7 +83,7 @@ const ToastClose = React.forwardRef< toast-close="" {...props} > - + )); ToastClose.displayName = ToastPrimitives.Close.displayName; diff --git a/src/lib/extrinsic.ts b/src/lib/extrinsic.ts index 9df9f70..dfcbdef 100644 --- a/src/lib/extrinsic.ts +++ b/src/lib/extrinsic.ts @@ -16,7 +16,7 @@ function getPropertyId(gameId: number) {} export async function playGame( gameType: 0 | 1 | 2, address: string, - handlePropertyDisplay: (data: any) => void + handlePropertyDisplay: (data: any) => Promise ) { try { const api = await getApi(); @@ -43,7 +43,8 @@ export async function playGame( console.log('The game info is: ', gameInfo); const propertyDisplay = await fetchPropertyForDisplay(139361966); - handlePropertyDisplay(propertyDisplay); + console.log(propertyDisplay); + await handlePropertyDisplay(propertyDisplay); // console.log(propertyDisplay); @@ -63,7 +64,7 @@ export async function playGame( } } -export async function submitGameAnswer(address: string, guess: any, gameId: number) { +export async function submitGameAnswer(address: string, guess: number, gameId: number) { try { const api = await getApi(); const injected = await web3FromAddress(address); diff --git a/src/types/index.ts b/src/types/index.ts index 9839adb..20dce2f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -13,11 +13,11 @@ export type GameData = { bedrooms: number; bathrooms: number; size: any; - address: string; - post_code: string; - features: string; - images?: string[]; - location?: { + // address: string; + // post_code: string; + // features: string; + images: string[]; + location: { latitude: any; longitude: any; }; From cf693fd2c272f8c8cc0de2e32473dd3c8dbb2052 Mon Sep 17 00:00:00 2001 From: izaakwalz Date: Mon, 8 Jul 2024 03:38:02 +0100 Subject: [PATCH 2/3] fix --- src/app/(dashboard)/leaderboard/page.tsx | 6 +----- src/app/(dashboard)/test/page.tsx | 2 +- src/config/site.ts | 1 + 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/app/(dashboard)/leaderboard/page.tsx b/src/app/(dashboard)/leaderboard/page.tsx index ba707f6..6d3f9ef 100644 --- a/src/app/(dashboard)/leaderboard/page.tsx +++ b/src/app/(dashboard)/leaderboard/page.tsx @@ -56,11 +56,7 @@ export default function Page() {
- Rounded avatar + Rounded avatar

Deal Real Dev

1Ay00011DY... diff --git a/src/app/(dashboard)/test/page.tsx b/src/app/(dashboard)/test/page.tsx index 38afbef..a2bc413 100644 --- a/src/app/(dashboard)/test/page.tsx +++ b/src/app/(dashboard)/test/page.tsx @@ -29,7 +29,7 @@ export default function HomePage() { const handlePlayGame = async () => { console.log('Button clicked'); try { - await playGame(0, '5FEda1GYvjMYcBiuRE7rb85QbD5bQNHuZajhRvHYTxm4PPz5', data => { + await playGame(0, '5FEda1GYvjMYcBiuRE7rb85QbD5bQNHuZajhRvHYTxm4PPz5', async data => { setPropertyDisplay(data); }); } catch (error) { diff --git a/src/config/site.ts b/src/config/site.ts index f03c340..a9e0e95 100644 --- a/src/config/site.ts +++ b/src/config/site.ts @@ -131,6 +131,7 @@ export const siteConfig = { latitude: 52.625284, longitude: 1.30124 }, + images: [], summary: 'Second floor apartment located a short stroll from the City centre, Good sized lounge, Kitchen/Diner, Two bedrooms, E-Suite & Bathroom, Double glazing & electric heating, Designated Parking Space.' } as GameData From 644e09e0708057c488d2cdad5e4355a1bb614b31 Mon Sep 17 00:00:00 2001 From: izaakwalz Date: Mon, 8 Jul 2024 04:05:22 +0100 Subject: [PATCH 3/3] fix --- src/app/(dashboard)/leaderboard/page.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/(dashboard)/leaderboard/page.tsx b/src/app/(dashboard)/leaderboard/page.tsx index 6d3f9ef..5509648 100644 --- a/src/app/(dashboard)/leaderboard/page.tsx +++ b/src/app/(dashboard)/leaderboard/page.tsx @@ -11,7 +11,7 @@ type LeaderProps = { winner?: boolean; }; -export function LeaderBoardCard({ points, winner }: LeaderProps) { +function LeaderBoardCard({ points, winner }: LeaderProps) { return (
@@ -30,7 +30,8 @@ export function LeaderBoardCard({ points, winner }: LeaderProps) {
); } -async function ChampionCard() { + +function ChampionCard() { return ( <>
@@ -51,12 +52,20 @@ async function ChampionCard() { ); } + export default function Page() { return (
- Rounded avatar + Rounded avatar

Deal Real Dev

1Ay00011DY...