From 6530fbc2169c3c9ee6a03ecb047131fa418dee67 Mon Sep 17 00:00:00 2001 From: melanke Date: Thu, 5 Dec 2024 10:37:49 -0300 Subject: [PATCH] Showing Builders without profile on BuildersGrid; Removing the checkedInCount, it's supposed to be implemented on a different task --- .../nextjs/components/batch/BuildersGrid.tsx | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/packages/nextjs/components/batch/BuildersGrid.tsx b/packages/nextjs/components/batch/BuildersGrid.tsx index 0088700..368a20f 100644 --- a/packages/nextjs/components/batch/BuildersGrid.tsx +++ b/packages/nextjs/components/batch/BuildersGrid.tsx @@ -1,15 +1,9 @@ import Link from "next/link"; import { useQuery } from "@tanstack/react-query"; import { Address } from "~~/components/scaffold-eth"; -import { useScaffoldReadContract } from "~~/hooks/scaffold-eth"; +import { useScaffoldEventHistory } from "~~/hooks/scaffold-eth"; const BuildersGrid = () => { - // Get total number of checked-in builders from contract - const { data: checkedInCount, isLoading: countLoading } = useScaffoldReadContract({ - contractName: "BatchRegistry", - functionName: "checkedInCounter", - }); - // Get builder profiles from filesystem const { data: profileBuilders = [], isLoading: profilesLoading } = useQuery({ queryKey: ["builders-profiles"], @@ -20,7 +14,14 @@ const BuildersGrid = () => { }, }); - if (countLoading || profilesLoading) { + // Get checked-in builders from contract events + const { data: events, isLoading: eventsLoading } = useScaffoldEventHistory({ + contractName: "BatchRegistry", + eventName: "CheckedIn", + fromBlock: 127324219n, + }); + + if (profilesLoading || eventsLoading) { return (
@@ -28,13 +29,13 @@ const BuildersGrid = () => { ); } + const buildersWithoutProfile = (events ?? []) + .map(event => event.args.builder) + .filter(address => address && !profileBuilders.includes(address)); + console.log(buildersWithoutProfile); + return (
-
-

Batch Members ({checkedInCount?.toString() || "0"} checked in)

-

Showing builders who have created their profiles

-
-
{profileBuilders.map((address, idx) => ( {
View Profile → - {checkedInCount && checkedInCount > 0 && ( - Checked In - )}
))} + {buildersWithoutProfile.map((address, idx) => ( +
+
+
+
+ No Profile +
+
+
+ ))}
);