File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
3
3
import Link from "next/link" ;
4
+ import CheckedInCounter from "../components/CheckedInCounter" ;
4
5
import type { NextPage } from "next" ;
5
6
import { BugAntIcon , MagnifyingGlassIcon } from "@heroicons/react/24/outline" ;
6
7
@@ -15,8 +16,7 @@ const Home: NextPage = () => {
15
16
</ h1 >
16
17
< p className = "text-center text-lg" > Get started by taking a look at your batch GitHub repository.</ p >
17
18
< p className = "text-lg flex gap-2 justify-center" >
18
- < span className = "font-bold" > Checked in builders count:</ span >
19
- < span > To Be Implemented</ span >
19
+ < CheckedInCounter />
20
20
</ p >
21
21
</ div >
22
22
Original file line number Diff line number Diff line change
1
+ import { useEffect , useState } from "react" ;
2
+ import { useScaffoldReadContract } from "~~/hooks/scaffold-eth" ;
3
+
4
+ const CheckInCount = ( ) => {
5
+ const [ feedback , setFeedback ] = useState < string > ( "" ) ;
6
+ const [ result , setResult ] = useState < string > ( ) ;
7
+
8
+ const {
9
+ data : checkedIn ,
10
+ isLoading : checkInLoading ,
11
+ error : checkInError ,
12
+ } = useScaffoldReadContract ( {
13
+ contractName : "BatchRegistry" ,
14
+ functionName : "checkedInCounter" ,
15
+ } ) ;
16
+
17
+ useEffect ( ( ) => {
18
+ if ( checkInError ) {
19
+ setFeedback ( "Something went wrong" ) ;
20
+ console . error ( checkInError ) ;
21
+ } else {
22
+ setResult ( checkInLoading ? "..." : String ( Number ( checkedIn ) ) ) ;
23
+ }
24
+ } , [ checkInError , checkInLoading , checkedIn ] ) ;
25
+
26
+ return (
27
+ < >
28
+ < span className = "font-bold" > Checked in builders count: { result } </ span >
29
+ { feedback && < p > { feedback } </ p > }
30
+ </ >
31
+ ) ;
32
+ } ;
33
+
34
+ export default CheckInCount ;
You can’t perform that action at this time.
0 commit comments