-
Notifications
You must be signed in to change notification settings - Fork 3
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
Submit grants page #8
Conversation
From #4 (comment) instead of creating an API endpoint for submitting the grant form, I used Next Server action wanted to try it out 😅 and it surprisingly works really nice! But please let me know if we should create API endpoint it should be pretty easy we just need to move the server action function body inside API route handler with little minor tweaks 🙌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing Shiv!! Thank you.
Left a comment to discuss, but approving it!
Also (could be another PR): could you attach a good seed for the database? So we can test locally easily (some builders, etc)
const SubmitButton = () => { | ||
const { pending } = useFormStatus(); | ||
const { isConnected, address: connectedAddress } = useAccount(); | ||
const { isBuilderPresent, isLoading: isFetchingBuilderData } = useBGBuilderData(connectedAddress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is happening on the client side, right?
An alternative could be to fetch the builder on the server since we already have the findUserByAddress
function (and we won't need an API endpoint), right?
What would be the pros/cons?
Not saying that we should change it! Just wondering and trying to understand. Client/Server is more confusing with the App router / server components / etc 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is happening on the client side, right?
An alternative could be to fetch the builder on the server since we already have the findUserByAddress function (and we won't need an API endpoint), right?
Yes its happening on client, actually I think we shouldn't use findUserByAddress
or any other direct talking with firebase on client components because I think this will expose firebase credentials / firebaseAdmin to client browser which we don't want right ?
Any component which uses "use client" directive, all its imported modules are shipped to clients browser ( ref 1 & ref 2 )
An alternative could be to fetch the builder on the server
Umm I think we can't do this right? Because we get to know builderAddress
only after when code reaches client browser and then user connects the wallet.
So a request has to be made in useEffect* (after first render).
I think we could only fetch builder on server if we prior know the the builder address even before first render on client (i.e if it would have been embeded in url param builders/[id]/.page.tsx
)
But yeah lol I am sure maybe missing something and might have taken your question in completely different direction 😅, please feel free to correct me 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I forgot that we are going to use the "BG way" (signing every write action)! You are right!
Usually, you'd get that data (builderAddress in this case) in the backend from the JWT token. We could do SIWE + emit JWT, but let's keep it as in BG.
Ohh yes yes, I have been thinking about this the plan I had in mind to seed data into local firebase emulator is : Create a Create a file And we can add a script inside Will create a PR for this 🙌 |
The seed stuff sounds great @technophile-04! The seed + script could even be inside the Merging this! (left a comment here: #8 (comment)) |
Description
Fixes #4
TLDR:
/api/builders/:builderAddress
Demo video :
Screen.Recording.2024-02-04.at.12.58.35.PM.13-03-56-294.mov
DONE:
Creating mock api routeUsed Next server actions instead