diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx
index e705005..9faac58 100644
--- a/pages/dashboard.tsx
+++ b/pages/dashboard.tsx
@@ -1,6 +1,6 @@
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
-import { getAccessToken, usePrivy, useWallets } from "@privy-io/react-auth";
+import { getAccessToken, getEmbeddedConnectedWallet, usePrivy, useWallets } from "@privy-io/react-auth";
import Head from "next/head";
import { useBalance } from 'wagmi';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -26,7 +26,7 @@ export default function DashboardPage() {
const [vaultData, setVaultData] = useState({ prehp: "0", vc: "0" });
const router = useRouter();
- const { ready, authenticated, user, logout,connectWallet, exportWallet, unlinkWallet, linkDiscord, unlinkDiscord, linkTwitter, unlinkTwitter,linkGoogle, unlinkGoogle } = usePrivy();
+ const { ready, authenticated, user, logout,exportWallet, linkWallet,unlinkWallet, linkDiscord, unlinkDiscord, linkTwitter, unlinkTwitter,linkGoogle, unlinkGoogle } = usePrivy();
const { wallets } = useWallets();
const { data: balanceData } = useBalance({
address: user?.wallet?.address as `0x${string}`,
@@ -38,7 +38,13 @@ export default function DashboardPage() {
if (ready && !authenticated) {
router.push("/");
}
- }, [ready, authenticated, router]);
+ if(ready){
+ if(username == "-1"){
+ router.push("/logincomplete");
+ }
+ }
+
+ }, [ready, authenticated, router, username]);
useEffect(() => {
async function fetchUsername() {
@@ -128,8 +134,8 @@ export default function DashboardPage() {
{vaultData.vc || "0"} VC
-
{user?.wallet?.address}
- {balance || 0} {token}
+ {/* {user?.wallet?.address}
+ {balance || 0} {token}
*/}
Pre-hunt Points
@@ -138,7 +144,7 @@ export default function DashboardPage() {
-
+
Socials
@@ -150,7 +156,7 @@ export default function DashboardPage() {
{user?.twitter ? "@"+user?.twitter.username : "-"}
-
@@ -162,7 +168,7 @@ export default function DashboardPage() {
{user?.discord ? "@"+user?.discord?.username : "-"}
-
+
{user?.discord ? "Unlink" : "Link"}
@@ -174,23 +180,45 @@ export default function DashboardPage() {
{user?.google ? "@"+user?.google?.email : "-"}
-
+
{user?.google ? "Unlink" : "Link"}
-
+
Wallets
-
+
+
+
+
+
+
+
+
W3B Wallet
+
+
{getEmbeddedConnectedWallet(wallets)?.address }
+
+
+ {/*
{unlinkWallet(wallet.address)}}>
+
+ */}
+
+
+
+
+
+
+
{
wallets.map((wallet)=>{
+ if(wallet.connectorType == "embedded"){return "";}
return (
-
-
-
+
+
+
{wallet.walletClientType}
@@ -198,12 +226,12 @@ export default function DashboardPage() {
{wallet.address}
- {/*
{unlinkWallet(wallet.address)}}>
-
- */}
- {wallet.connectorType == "embedded" && (
-
- )}
+ { wallet.linked ?
{unlinkWallet(wallet.address)}}>
+
+ :
+
+ }
+
);
@@ -211,13 +239,13 @@ export default function DashboardPage() {
}
-
+
- Connect New Wallet
+ + Connect New Wallet
diff --git a/pages/logincomplete.tsx b/pages/logincomplete.tsx
new file mode 100644
index 0000000..4228e20
--- /dev/null
+++ b/pages/logincomplete.tsx
@@ -0,0 +1,71 @@
+import { usePrivy } from "@privy-io/react-auth";
+import Head from "next/head";
+import { useRouter } from "next/router";
+import { SetStateAction, useState } from "react";
+
+export default function LoginComplete() {
+ const [username, setUsername] = useState("");
+ const [error, setError] = useState("");
+ const {ready, user} = usePrivy();
+ const router = useRouter();
+ const handleUsernameChange = (e: { target: { value: SetStateAction; }; }) => {
+ setUsername(e.target.value);
+ setError("");
+ };
+
+ const handleClaim = async () => {
+ try {
+ const response = await fetch(
+ `https://vps.playpoolstudios.com/metahunt/api/web/validate_username.php?username=${username}`
+ );
+ const data = await response.text();
+
+ if (data === "0") {
+ await fetch(
+ `https://vps.playpoolstudios.com/metahunt/api/web/set_username.php?id=${user?.id}&username=${username}`
+ );
+ // Optionally, handle successful username set
+ console.log("Username successfully set!");
+ router.push("/dashboard");
+ } else {
+ setUsername("");
+ setError(`Sorry, ${username} is not available`);
+ }
+ } catch (error) {
+ console.error("Error:", error);
+ setError("An error occurred. Please try again.");
+ }
+ };
+
+ return (
+ <>
+
+ Complete Login
+
+
+
+
Let's Complete your Login
+
Enter your unique username
+
+ {error &&
{error}
}
+
+ Claim
+
+
+
+
+ >
+ );
+}