ff
This commit is contained in:
parent
0ca5e560f9
commit
c36083541b
|
|
@ -1,7 +1,6 @@
|
|||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getAccessToken, usePrivy } from "@privy-io/react-auth";
|
||||
//import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import Head from "next/head";
|
||||
import { useBalance } from 'wagmi';
|
||||
|
||||
|
|
@ -19,12 +18,13 @@ async function verifyToken() {
|
|||
|
||||
export default function DashboardPage() {
|
||||
const [verifyResult, setVerifyResult] = useState(0);
|
||||
const [username, setUsername] = useState('');
|
||||
const [vaultData, setVaultData] = useState({ prehp: "0", vc: "0" });
|
||||
const router = useRouter();
|
||||
|
||||
const { ready, authenticated, user, logout, linkTwitter, unlinkTwitter, unlinkDiscord, linkDiscord, unlinkWallet, linkWallet } = usePrivy();
|
||||
const { data: balanceData } = useBalance({
|
||||
// address: '0x4557B18E779944BFE9d78A672452331C186a9f48'
|
||||
address: user?.wallet?.address as `0x${string}`,
|
||||
address: user?.wallet?.address as `0x${string}`,
|
||||
});
|
||||
const balance = balanceData?.formatted;
|
||||
const token = balanceData?.symbol;
|
||||
|
|
@ -35,6 +35,35 @@ export default function DashboardPage() {
|
|||
}
|
||||
}, [ready, authenticated, router]);
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchUsername() {
|
||||
if (ready) {
|
||||
try {
|
||||
const response = await fetch(`https://vps.playpoolstudios.com/metahunt/api/launcher/get_display_name_public.php?id=${user?.id}`);
|
||||
const data = await response.text();
|
||||
setUsername(data); // Assuming the response contains the display name under `display_name`
|
||||
} catch (error) {
|
||||
console.error("Error fetching username:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchVaultData() {
|
||||
if (user?.id) {
|
||||
try {
|
||||
const response = await fetch(`http://vps.playpoolstudios.com/metahunt/api/launcher/get_vault.php?id=${user?.id}`);
|
||||
const data = await response.json();
|
||||
setVaultData({ prehp: data.prehp, vc: data.vc });
|
||||
} catch (error) {
|
||||
console.error("Error fetching vault data:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fetchUsername();
|
||||
fetchVaultData();
|
||||
}, [ready]);
|
||||
|
||||
const numAccounts = user?.linkedAccounts?.length || 0;
|
||||
const canRemoveAccount = numAccounts > 1;
|
||||
|
||||
|
|
@ -49,14 +78,14 @@ export default function DashboardPage() {
|
|||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Account Settings</title>
|
||||
<title>W3B Games Dashboard</title>
|
||||
</Head>
|
||||
|
||||
<main className="flex flex-col min-h-screen px-4 sm:px-20 py-6 sm:py-10 bg-black text-white">
|
||||
{ready && authenticated ? (
|
||||
<>
|
||||
<div className="flex flex-row justify-between">
|
||||
<h1 className="text-2xl font-semibold text-white">Welcome Warlock,</h1>
|
||||
<h1 className="text-2xl font-semibold text-white">Welcome {username || "User"},</h1>
|
||||
<button
|
||||
onClick={logout}
|
||||
className="text-sm bg-red-500 hover:bg-red-700 py-2 px-4 rounded-md text-violet-100"
|
||||
|
|
@ -65,18 +94,18 @@ export default function DashboardPage() {
|
|||
</button>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-center">
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-s">Vault Credits</h1>
|
||||
<h1 className="text-4xl flex justify-center">1 VC</h1>
|
||||
</div>
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-xs">{user?.wallet?.address}</h1>
|
||||
<h1 className="text-4xl flex justify-center">{balance || 0} {token}</h1>
|
||||
</div>
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-s">Pre-hunt Points</h1>
|
||||
<h1 className="text-4xl flex justify-center">1 PHP</h1>
|
||||
</div>
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-s">Vault Credits</h1>
|
||||
<h1 className="text-4xl flex justify-center">{vaultData.vc || "0"} VC</h1>
|
||||
</div>
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-xs">{user?.wallet?.address}</h1>
|
||||
<h1 className="text-4xl flex justify-center">{balance || 0} {token}</h1>
|
||||
</div>
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-s">Pre-hunt Points</h1>
|
||||
<h1 className="text-4xl flex justify-center">{vaultData.prehp || "0"} PHP</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-12 flex gap-4 flex-wrap">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user