diff --git a/packages/nextjs/components/Header.tsx b/packages/nextjs/components/Header.tsx index f24a1de..a40bd6f 100644 --- a/packages/nextjs/components/Header.tsx +++ b/packages/nextjs/components/Header.tsx @@ -4,6 +4,8 @@ import React, { useCallback, useRef, useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; +import { UserBadges } from "./UserBadges"; +import { useAccount } from "wagmi"; import { Bars3Icon, BugAntIcon } from "@heroicons/react/24/outline"; import { FaucetButton, RainbowKitCustomConnectButton } from "~~/components/scaffold-eth"; import { useOutsideClick } from "~~/hooks/scaffold-eth"; @@ -58,6 +60,8 @@ export const HeaderMenuLinks = () => { export const Header = () => { const [isDrawerOpen, setIsDrawerOpen] = useState(false); const burgerMenuRef = useRef(null); + const { isConnected } = useAccount(); + useOutsideClick( burgerMenuRef, useCallback(() => setIsDrawerOpen(false), []), @@ -102,6 +106,7 @@ export const Header = () => {
+ {isConnected && }
diff --git a/packages/nextjs/components/UserBadges.tsx b/packages/nextjs/components/UserBadges.tsx new file mode 100644 index 0000000..7abb074 --- /dev/null +++ b/packages/nextjs/components/UserBadges.tsx @@ -0,0 +1,39 @@ +import { useAccount } from "wagmi"; +import { BookmarkSquareIcon, IdentificationIcon, SignalSlashIcon } from "@heroicons/react/24/outline"; +import { useScaffoldReadContract } from "~~/hooks/scaffold-eth"; + +export const UserBadges = () => { + const { address } = useAccount(); + + const { data: isBuilderOfBatch11 } = useScaffoldReadContract({ + contractName: "BatchRegistry", + functionName: "allowList", + args: [address], + }); + + const { data: contractAddress } = useScaffoldReadContract({ + contractName: "BatchRegistry", + functionName: "yourContractAddress", + args: [address], + }); + + const madeCheckin = contractAddress && contractAddress !== "0x0000000000000000000000000000000000000000"; + + return ( +
+ {madeCheckin ? ( +
+ +
+ ) : isBuilderOfBatch11 ? ( +
+ +
+ ) : ( +
+ +
+ )} +
+ ); +};