Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch and Display Builder Count from BatchRegistry Contract #17

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions packages/nextjs/app/page.tsx
Superior212 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
import Link from "next/link";
import type { NextPage } from "next";
import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline";
import { useScaffoldReadContract } from "~~/hooks/scaffold-eth";

const Home: NextPage = () => {
const {
data: checkedInCounter,
error,
isLoading: contractLoading,
} = useScaffoldReadContract({
contractName: "BatchRegistry",
functionName: "checkedInCounter",
});

return (
<>
<div className="flex items-center flex-col flex-grow pt-10">
Expand All @@ -14,10 +24,23 @@ const Home: NextPage = () => {
<span className="block text-4xl font-bold">Batch 10</span>
</h1>
<p className="text-center text-lg">Get started by taking a look at your batch GitHub repository.</p>
<p className="text-lg flex gap-2 justify-center">
<span className="font-bold">Checked in builders count:</span>
<span>To Be Implemented</span>
</p>

{error ? (
<div className="p-4 rounded-lg bg-red-100 text-red-700" role="alert">
<p>Error fetching contract data: {error.message}</p>
</div>
) : (
<div className="text-lg flex gap-2 justify-center">
<span className="font-bold">Checked in builders count:</span>
{contractLoading ? (
<span className="animate-pulse">
<div className="h-6 bg-gray-200 rounded w-12"></div>
</span>
) : (
<span>{checkedInCounter !== undefined ? Number(checkedInCounter) : "0"}</span>
)}
</div>
)}
</div>

<div className="flex-grow bg-base-300 w-full mt-16 px-8 py-12">
Expand Down
Loading