diff --git a/packages/nextjs/components/CheckInFlag.tsx b/packages/nextjs/components/CheckInFlag.tsx new file mode 100644 index 0000000..523db1a --- /dev/null +++ b/packages/nextjs/components/CheckInFlag.tsx @@ -0,0 +1,20 @@ +import { useAccount } from "wagmi"; +import { useIsCheckedIn } from "~~/hooks/scaffold-eth/useIsCheckedIn"; + +export const CheckInFlag = () => { + const isCheckedIn = useIsCheckedIn(); + const { isConnected } = useAccount(); + return ( + + ); +}; diff --git a/packages/nextjs/components/Footer.tsx b/packages/nextjs/components/Footer.tsx index 92b3c62..d40d95d 100644 --- a/packages/nextjs/components/Footer.tsx +++ b/packages/nextjs/components/Footer.tsx @@ -1,11 +1,12 @@ -import React from "react"; import Link from "next/link"; +import { BatchMemberLogo } from "./assets/BatchMemberLogo"; import { hardhat } from "viem/chains"; import { CurrencyDollarIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; import { HeartIcon } from "@heroicons/react/24/outline"; import { SwitchTheme } from "~~/components/SwitchTheme"; import { BuidlGuidlLogo } from "~~/components/assets/BuidlGuidlLogo"; import { Faucet } from "~~/components/scaffold-eth"; +import { useCheckIsMember } from "~~/hooks/scaffold-eth/useCheckIsMember"; import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; import { useGlobalState } from "~~/services/store/store"; @@ -16,6 +17,7 @@ export const Footer = () => { const nativeCurrencyPrice = useGlobalState(state => state.nativeCurrency.price); const { targetNetwork } = useTargetNetwork(); const isLocalNetwork = targetNetwork.id === hardhat.id; + const isMember = useCheckIsMember(); return (
@@ -23,11 +25,15 @@ export const Footer = () => {
{nativeCurrencyPrice > 0 && ( -
+
{nativeCurrencyPrice.toFixed(2)}
+ {/* Conditionally renders the batch member logo is they are in the allow list */} +
+ +
)} {isLocalNetwork && ( diff --git a/packages/nextjs/components/Header.tsx b/packages/nextjs/components/Header.tsx index f24a1de..62d5a91 100644 --- a/packages/nextjs/components/Header.tsx +++ b/packages/nextjs/components/Header.tsx @@ -4,6 +4,7 @@ import React, { useCallback, useRef, useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; +import { CheckInFlag } from "./CheckInFlag"; import { Bars3Icon, BugAntIcon } from "@heroicons/react/24/outline"; import { FaucetButton, RainbowKitCustomConnectButton } from "~~/components/scaffold-eth"; import { useOutsideClick } from "~~/hooks/scaffold-eth"; @@ -102,6 +103,7 @@ export const Header = () => {
+
diff --git a/packages/nextjs/components/assets/BatchMemberLogo.tsx b/packages/nextjs/components/assets/BatchMemberLogo.tsx new file mode 100644 index 0000000..761e020 --- /dev/null +++ b/packages/nextjs/components/assets/BatchMemberLogo.tsx @@ -0,0 +1,34 @@ +export const BatchMemberLogo = ({ className }: { className: string }) => { + return ( + + + + + + + + + + + + ); +}; diff --git a/packages/nextjs/hooks/scaffold-eth/useCheckIsMember.ts b/packages/nextjs/hooks/scaffold-eth/useCheckIsMember.ts new file mode 100644 index 0000000..42f18c8 --- /dev/null +++ b/packages/nextjs/hooks/scaffold-eth/useCheckIsMember.ts @@ -0,0 +1,14 @@ +import { useScaffoldReadContract } from "./useScaffoldReadContract"; +import { useAccount } from "wagmi"; + +//Checks whether they are a member of batch 8! +export const useCheckIsMember = () => { + const { address } = useAccount(); + const { data } = useScaffoldReadContract({ + contractName: "BatchRegistry", + functionName: "allowList", + args: [address], + }); + + return data; +}; diff --git a/packages/nextjs/hooks/scaffold-eth/useIsCheckedIn.ts b/packages/nextjs/hooks/scaffold-eth/useIsCheckedIn.ts new file mode 100644 index 0000000..1d97534 --- /dev/null +++ b/packages/nextjs/hooks/scaffold-eth/useIsCheckedIn.ts @@ -0,0 +1,15 @@ +import { useScaffoldReadContract } from "./useScaffoldReadContract"; +import { useAccount } from "wagmi"; + +export const useIsCheckedIn = () => { + const { address } = useAccount(); + const { data } = useScaffoldReadContract({ + contractName: "BatchRegistry", + functionName: "yourContractAddress", + args: [address], + }); + if (data == "0x0000000000000000000000000000000000000000") { + return false; + } + return data; +};