From e63e22ba3e1aa8af64fce0727a9d2b505d9f0850 Mon Sep 17 00:00:00 2001 From: "sewmina7@gmail.com" Date: Sun, 16 Jun 2024 18:56:36 +0530 Subject: [PATCH] before leaderboard fetch --- app/page.tsx | 58 +++++++++++++++++++++++++++++++++++------------ package-lock.json | 9 ++++++++ package.json | 1 + 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 06599df..10b915a 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -3,6 +3,8 @@ import React, { useState, useEffect } from "react"; import { SunIcon, MoonIcon } from "@heroicons/react/solid"; import { PrivyProvider, usePrivy } from "@privy-io/react-auth"; +import { FaTwitter, FaWallet } from "react-icons/fa"; +import { CheckIcon } from "@heroicons/react/outline"; // For the check mark icon // Helper functions to generate pseudo data const generateRandomName = () => { @@ -35,9 +37,11 @@ const generateTableData = (rows) => { const tableData = generateTableData(10); function Home() { - const { login, user, ready, logout } = usePrivy(); + const { login, user, ready, logout, linkTwitter, unlinkTwitter } = usePrivy(); const [darkMode, setDarkMode] = useState(true); - + const [twitterConnected, setTwitterConnected] = useState(false); // State to track Twitter connection + const [walletConnected, setWalletConnected] = useState(false); // State to track Wallet connection + const [incrementNumber, setIncrementNumber] = useState(1); useEffect(() => { if (darkMode) { document.documentElement.classList.add("dark"); @@ -46,6 +50,13 @@ function Home() { } }, [darkMode]); + useEffect(() => { + const intervalId = setInterval(() => { + setIncrementNumber((prevNumber) => prevNumber + 1); + }, 5000); + return () => clearInterval(intervalId); // Clean up the interval on component unmount + }, []); + const toggleDarkMode = () => { setDarkMode(!darkMode); document.documentElement.classList.toggle("dark", !darkMode); @@ -53,7 +64,7 @@ function Home() { const postLoginAPI = async (usertag) => { try { - const response = await fetch('https://vps.playpoolstudios.com/callfi/register_twitter_user.php?tag='+usertag); + const response = await fetch('https://vps.playpoolstudios.com/callfi/register_twitter_user.php?tag=' + usertag); if (!response.ok) { throw new Error('Network response was not ok'); @@ -61,6 +72,7 @@ function Home() { const data = await response.json(); console.log('API call successful:', data); + setTwitterConnected(true); // Set Twitter connection state to true on successful API call } catch (error) { console.error('Error during API call:', error); } @@ -68,11 +80,15 @@ function Home() { useEffect(() => { if (ready && user) { - // Assuming user object contains twitter handle at user.profile.twitter const username = user.twitter?.username ? `@${user.twitter.username}` : '@unknownUser'; - if(username != "@unknownUser"){ + if (username !== "@unknownUser") { postLoginAPI(username); } + // Assume we have a way to check if the wallet is connected + const walletStatus = user.wallet; // This is an assumption; replace it with actual wallet connection check + if (walletStatus) { + setWalletConnected(true); + } } }, [ready, user]); @@ -84,17 +100,31 @@ function Home() { - {!ready ? ( -

Loading...

- ) : user ? ( - - ) : ( - - )} + {!ready ? ( +

Loading...

+ ) : user ? ( + + ) : ( + + )} +
diff --git a/package-lock.json b/package-lock.json index 61ebc48..1809a7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "next": "14.2.4", "react": "^18", "react-dom": "^18", + "react-icons": "^5.2.1", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7" }, @@ -7421,6 +7422,14 @@ "react": "^18.3.1" } }, + "node_modules/react-icons": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz", + "integrity": "sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", diff --git a/package.json b/package.json index 00e1a9d..5a90647 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "next": "14.2.4", "react": "^18", "react-dom": "^18", + "react-icons": "^5.2.1", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7" },