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

feat: enhance homepage and add builders grid #20

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

gboigwe
Copy link
Contributor

@gboigwe gboigwe commented Nov 20, 2024

Enhanced Homepage and Builders Grid

Changes Made

  • Added BuildersGrid component showing registered builders
  • Created API route to fetch builder addresses from filesystem
  • Connected grid to personal builder pages
  • Enhanced homepage dark mode visibility
  • Updated styling for better UX

Implementation Details

  • Scans filesystem for builder pages in /builders directory
  • Displays builder profiles in responsive grid layout
  • Maintains consistent styling with existing components

[Add screenshots of homepage and grid in light/dark modes]

Screenshot for the Checked Builders Count:

image

Screenshot for the number of registered builders page:

image

Additional Information

Related Issues

_Closes #4 _

Your ENS/address: 0x5cc8Be96B1C9A68F57a73b5bEa60cF5D890055A1

Copy link

vercel bot commented Nov 20, 2024

@gboigwe is attempting to deploy a commit to the BuidlGuidl Team on Vercel.

A member of the Team first needs to authorize it.

@gboigwe
Copy link
Contributor Author

gboigwe commented Nov 20, 2024

Although not entirely completed as I still need to work on some console errors I found, feel free to make suggestions and or contribute.
And if there is any issue at all please point it out, even if it is the console error issue, please still point it out

Copy link
Contributor

@melanke melanke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job. Just a few ideas for improvements

packages/nextjs/app/page.tsx Outdated Show resolved Hide resolved
packages/nextjs/components/batch/BuildersGrid.tsx Outdated Show resolved Hide resolved
Comment on lines 30 to 45
useEffect(() => {
fetch("/api/builders")
.then(res => res.json())
.then(addresses => {
const buildersList = addresses.map((address: string, index: number) => ({
id: index,
address: address,
}));
setBuilders(buildersList);
setIsLoading(false);
})
.catch(error => {
console.error("Error fetching builders:", error);
setIsLoading(false);
});
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a matter of preference, but react-query would fit well here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, beside getting the builders by their profile pages, we could get whoever made checkin, even the ones without a profile page. Check this discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get the details from the builders that checked-in?
Okay, I will try it out and see, but not sure how to figure it, but I will definitely try all my best. Thanks so much

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can grab the second parameter of this event:

event CheckedIn(bool first, address builder, address checkInContract);

There's an example on how to do this on the Challenge-4-Dex.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gboigwe, this one is still open. We want to display all checked-in builders, not just those with a personal profile.

@gboigwe
Copy link
Contributor Author

gboigwe commented Nov 23, 2024

Made some changes as suggested by @melanke and @phipsae and I have committed them. Sure about the react-query though yet but any other suggestions

@phipsae
Copy link
Collaborator

phipsae commented Nov 24, 2024

@gboigwe thanks, you def tackle one of the more difficult tasks!

Pls look into the comments @melanke made and work on them before you ask for a review.
Pls use useScaffoldReadContract instead of useContractRead for example.
Also it shows me that you touched the builders profiles, there shouldn't be any changes.

Let me know then I'll have a review!

@gboigwe
Copy link
Contributor Author

gboigwe commented Nov 24, 2024

Okay, thank you.

I actually did used the useScaffoldReadContract

I will check to confirm why that was not seen. Thank you

@gboigwe
Copy link
Contributor Author

gboigwe commented Nov 24, 2024

Oh and for the builders profile, remember that I used my builders page before for testing but @melanke suggested that I pull his as it was merged already, so I removed mine from the PR and used his

Copy link
Collaborator

@phipsae phipsae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

Here’s a general tip: focus solely on the issue you’ve chosen to work on and avoid making unrelated changes. Only modify the files necessary for that specific task.

I understand it can be challenging at first, but that’s exactly why we have this course to guide you! 😊

packages/nextjs/contracts/deployedContracts.ts Outdated Show resolved Hide resolved
packages/nextjs/next.config.js Outdated Show resolved Hide resolved
Comment on lines 10 to 28
const {
data: checkedInCount,
isLoading,
error,
} = useScaffoldReadContract({
contractName: "BatchRegistry",
functionName: "checkedInCounter",
});

const displayCount = isLoading ? (
<span className="loading loading-spinner loading-sm text-primary"></span>
) : error ? (
"Error loading"
) : typeof checkedInCount === "bigint" ? (
checkedInCount.toString()
) : (
"0"
);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is out of scope and relates to issue #6. Please remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this. It belongs to issue #6. If you want to include the "checkedInCounter", create a separate PR for it.

In a "real-world" scenario, when working on an issue, ensure you only add code that falls within its scope.

packages/nextjs/app/page.tsx Outdated Show resolved Hide resolved
packages/nextjs/app/page.tsx Outdated Show resolved Hide resolved
packages/nextjs/app/page.tsx Outdated Show resolved Hide resolved
@phipsae
Copy link
Collaborator

phipsae commented Nov 28, 2024

Hi @gboigwe, thanks for the updates!

There are just two more points left to address. Please always make sure to review the conversation for details.

  1. Instead of limiting to builders with profile pages, we sould include everyone who has checked in, even those without a profile. Refer to this discussion. You can use the CheckedIn event: event CheckedIn(bool first, address builder, address checkInContract).
  2. Pls don't solve other issue in this PR discussion (no checkedIn counter, that's another issue, if you want to solve it, create another PR)

Almost done :)

@gboigwe
Copy link
Contributor Author

gboigwe commented Nov 28, 2024

Okay, thank you. Thanks for you patience with me too

@gboigwe
Copy link
Contributor Author

gboigwe commented Nov 28, 2024

I will make sure to put that into effect.
@melanke has been helping me out all the way too, I have to acknowledge and commend his support

@phipsae
Copy link
Collaborator

phipsae commented Nov 28, 2024

Okay, thank you. Thanks for you patience with me too

Of course, that's why I am here! So no worries at all. It's all about learning.
@melanke thank you so much!

@melanke
Copy link
Contributor

melanke commented Dec 1, 2024

@phipsae This code doesn't work because the fromBlock:

const { data: events, isLoading: eventsLoading } = useScaffoldEventHistory({
    contractName: "BatchRegistry",
    eventName: "CheckedIn",
    fromBlock: 127324219n,
  });

Which is strange, because I got the Contract Creation block and subtracted 10, as we did on the challenges:

image

But it works when we put zero on fromBlock.

Do you know what's happening?

@phipsae
Copy link
Collaborator

phipsae commented Dec 2, 2024

@phipsae This code doesn't work because the fromBlock:

const { data: events, isLoading: eventsLoading } = useScaffoldEventHistory({
    contractName: "BatchRegistry",
    eventName: "CheckedIn",
    fromBlock: 127324219n,
  });

Which is strange, because I got the Contract Creation block and subtracted 10, as we did on the challenges:

image

But it works when we put zero on fromBlock.

Do you know what's happening?

No idea, right now. As soon as you push the code, I can have a look at it.

@phipsae
Copy link
Collaborator

phipsae commented Dec 5, 2024

@phipsae This code doesn't work because the fromBlock:

const { data: events, isLoading: eventsLoading } = useScaffoldEventHistory({
    contractName: "BatchRegistry",
    eventName: "CheckedIn",
    fromBlock: 127324219n,
  });

Which is strange, because I got the Contract Creation block and subtracted 10, as we did on the challenges:
image
But it works when we put zero on fromBlock.
Do you know what's happening?

No idea, right now. As soon as you push the code, I can have a look at it.

I tested it locally, and it works in my environment. Do you have your NEXT_PUBLIC_ALCHEMY_API_KEY set? (Although, if block 0 works, it should be fine.)

…dInCount, it's supposed to be implemented on a different task
Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
batch11.buidlguidl.com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 5:24pm

Copy link
Collaborator

@phipsae phipsae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!
Only these little comments below and then we are finally ready to merge.

packages/nextjs/components/batch/BuildersGrid.tsx Outdated Show resolved Hide resolved
packages/nextjs/components/batch/BuildersGrid.tsx Outdated Show resolved Hide resolved
@phipsae
Copy link
Collaborator

phipsae commented Dec 12, 2024

Thanks a lot for your effort! Finally lets merge 🎉

@phipsae phipsae merged commit 49dc849 into BuidlGuidl:main Dec 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants