From 983e8aa0600c04fdb1b0f5fdd72d8d452fa28ed2 Mon Sep 17 00:00:00 2001 From: Luciano Oliva Bianco Date: Tue, 24 Sep 2024 00:12:33 -0300 Subject: [PATCH] UI improvements --- packages/nextjs/app/myProfile/MyProfile.tsx | 14 ++- packages/nextjs/components/Header.tsx | 125 ++++++++++++-------- 2 files changed, 86 insertions(+), 53 deletions(-) diff --git a/packages/nextjs/app/myProfile/MyProfile.tsx b/packages/nextjs/app/myProfile/MyProfile.tsx index 9cec694..1314af4 100644 --- a/packages/nextjs/app/myProfile/MyProfile.tsx +++ b/packages/nextjs/app/myProfile/MyProfile.tsx @@ -6,6 +6,7 @@ import { MyHoldings } from "./_components/MyHoldings"; import { ProfilePictureUpload } from "./_components/ProfilePictureUpload"; import { NextPage } from "next"; import { useAccount } from "wagmi"; +import { PencilIcon } from "@heroicons/react/24/outline"; import { Address, RainbowKitCustomConnectButton } from "~~/components/scaffold-eth"; import { InputBase } from "~~/components/scaffold-eth"; import { useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth"; @@ -135,7 +136,7 @@ export const MyProfile: NextPage = () => { return (
{/* User Profile Section */} -
+
{/* Profile Picture */}
{
*/} {/* User Info Section */} -
+
{isEditing ? ( ) : ( @@ -193,11 +194,12 @@ export const MyProfile: NextPage = () => { {/* Edit/Cancel Button */} {isEditing ? ( ) : ( )} @@ -211,7 +213,7 @@ export const MyProfile: NextPage = () => { ) : (
{/* Wrap Image in a div and set explicit width/height */} @@ -232,7 +234,7 @@ export const MyProfile: NextPage = () => { {/* Tabs Section */}
-
+
{ * Site header */ export const Header = () => { - const [isDrawerOpen, setIsDrawerOpen] = useState(false); + // const [isDrawerOpen, setIsDrawerOpen] = useState(false); const [isMenuOpen, setIsMenuOpen] = useState(false); // const pathname = usePathname(); // Add this line to track the active route const { address: connectedAddress, isConnected } = useAccount(); + const { writeContractAsync: usdcWriteAsync } = useScaffoldWriteContract("MockUSDC"); const { data: profileInfo } = useScaffoldReadContract({ contractName: "ProfileInfo", @@ -70,69 +73,97 @@ export const Header = () => { watch: true, }); + const { data: usdcBalance } = useScaffoldReadContract({ + contractName: "MockUSDC", + functionName: "balanceOf", + args: [connectedAddress], + watch: true, + }); + const defaultProfilePicture = "https://ipfs.io/ipfs/QmVCvzEQHFKzAYSsou8jEJtWdFj31n2XgPpbLjbZqui4YY"; const profilePicture = profileInfo && profileInfo[2] ? profileInfo[2] : defaultProfilePicture; - const burgerMenuRef = useRef(null); - useOutsideClick( - burgerMenuRef, - useCallback(() => setIsDrawerOpen(false), []), - ); + // const burgerMenuRef = useRef(null); + // useOutsideClick( + // burgerMenuRef, + // useCallback(() => setIsDrawerOpen(false), []), + // ); const menuRef = useRef(null); + const pathname = usePathname(); + useOutsideClick( menuRef, useCallback(() => setIsMenuOpen(false), []), ); + const handleMintUSDC = async () => { + try { + await usdcWriteAsync({ + functionName: "mint", + args: [connectedAddress, BigInt(100e6)], // Mint 1 USDC + }); + + notification.success("USDC Minted Successfully"); + } catch (error) { + console.error("Error during minting:", error); + + // Log the error and notify the user + notification.error("Minting failed, please try again."); + } + }; + return (
-
-
- - {isDrawerOpen && ( -
    { - setIsDrawerOpen(false); - }} - > - -
- )} -
- -
- DARTE -
+
+ + + +
+ +
+ + + DARTE + -
    - -
{isConnected ? ( -
setIsMenuOpen(!isMenuOpen)} - style={{ - backgroundImage: `url(${profilePicture})`, - backgroundSize: "cover", - backgroundPosition: "center", - }} - >
+ <> +
+ {/* */} + + {/* Wrap Image in a div and set explicit width/height */} +
+ USDC Logo +
+ +

{usdcBalance ? Number(usdcBalance) / 1e6 : 0}

+
+
setIsMenuOpen(!isMenuOpen)} + style={{ + backgroundImage: `url(${profilePicture})`, + backgroundSize: "cover", + backgroundPosition: "center", + }} + >
+ ) : ( )}