Skip to content

Commit 773470e

Browse files
authored
Merge pull request #47 from nnennaokoye/feat/connected-wallet-info
connected wallet info
2 parents f83904e + d6a0b5f commit 773470e

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"use client";
2+
3+
import { zeroAddress } from "viem";
4+
import { useAccount } from "wagmi";
5+
import { CheckCircleIcon, UserGroupIcon, XCircleIcon } from "@heroicons/react/24/solid";
6+
import { useScaffoldReadContract } from "~~/hooks/scaffold-eth";
7+
8+
export const BatchStatusIndicators = () => {
9+
const { address: userAddress } = useAccount();
10+
11+
// Check if address is in allowList (batch member)
12+
const { data: allowListStatus, isLoading: isLoadingAllowList } = useScaffoldReadContract({
13+
contractName: "BatchRegistry",
14+
functionName: "allowList",
15+
args: [userAddress ?? zeroAddress],
16+
chainId: 42161,
17+
});
18+
19+
// Check if address has checked in
20+
const { data: contractAddress, isLoading: isLoadingContractAddress } = useScaffoldReadContract({
21+
contractName: "BatchRegistry",
22+
functionName: "yourContractAddress",
23+
args: [userAddress ?? zeroAddress],
24+
chainId: 42161,
25+
});
26+
27+
const isInBatch = !!allowListStatus;
28+
const isCheckedIn = contractAddress && contractAddress !== zeroAddress;
29+
30+
if (!userAddress) return null;
31+
32+
const isLoading = isLoadingAllowList || isLoadingContractAddress;
33+
34+
return (
35+
<div className="flex items-center space-x-2 mx-1">
36+
{isLoading ? (
37+
<div className="loading loading-spinner loading-xs"></div>
38+
) : (
39+
<>
40+
{/* Batch Membership Indicator */}
41+
<div
42+
className={`tooltip tooltip-bottom ${!isInBatch ? "tooltip-error" : ""}`}
43+
data-tip={isInBatch ? "Batch Member" : "Not a Batch Member"}
44+
>
45+
<div
46+
className={`flex items-center justify-center w-6 h-6 rounded-full ${isInBatch ? "bg-primary/20" : "bg-error/20"}`}
47+
>
48+
<UserGroupIcon className={`h-5 w-5 ${isInBatch ? "text-primary font-bold" : "text-error"}`} />
49+
</div>
50+
</div>
51+
52+
{/* Check-in Status Indicator */}
53+
<div
54+
className={`tooltip tooltip-bottom ${!isCheckedIn ? "tooltip-error" : ""}`}
55+
data-tip={isCheckedIn ? "Checked In" : "Not Checked In"}
56+
>
57+
<div
58+
className={`flex items-center justify-center w-6 h-6 rounded-full ${isCheckedIn ? "bg-success/20" : "bg-error/20"}`}
59+
>
60+
{isCheckedIn ? (
61+
<CheckCircleIcon className="h-4 w-4 text-success" />
62+
) : (
63+
<XCircleIcon className="h-4 w-4 text-error" />
64+
)}
65+
</div>
66+
</div>
67+
</>
68+
)}
69+
</div>
70+
);
71+
};

packages/nextjs/components/Header.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Link from "next/link";
66
import { usePathname } from "next/navigation";
77
import { hardhat } from "viem/chains";
88
import { Bars3Icon, BugAntIcon, UserGroupIcon } from "@heroicons/react/24/outline";
9+
import { BatchStatusIndicators } from "~~/components/BatchStatusIndicators";
910
import { FaucetButton, RainbowKitCustomConnectButton } from "~~/components/scaffold-eth";
1011
import { useOutsideClick, useTargetNetwork } from "~~/hooks/scaffold-eth";
1112

@@ -100,7 +101,10 @@ export const Header = () => {
100101
</ul>
101102
</div>
102103
<div className="navbar-end grow mr-4">
103-
<RainbowKitCustomConnectButton />
104+
<div className="flex items-center gap-2">
105+
<BatchStatusIndicators />
106+
<RainbowKitCustomConnectButton />
107+
</div>
104108
{isLocalNetwork && <FaucetButton />}
105109
</div>
106110
</div>

0 commit comments

Comments
 (0)