Aakash Connect Request new account frontend to backend - #79
Conversation
❌ Deploy Preview for juno-dashboard failed. Why did it fail? →
|
Greptile SummaryThis PR connects the account request frontend to the Juno SDK backend by replacing placeholder implementations in Key changes:
Areas needing improvement:
PR score: 79/100 — The core integration is solid and well-structured. The two points above (debug logs and toast deduplication) are the main items to address before merging. Confidence Score: 3/5
Important Files Changed
|
| success: true, | ||
| }; | ||
| } catch (error) { | ||
| console.error("Error requesting new account:", error.body); |
There was a problem hiding this comment.
console.error calls should be removed
The PR checklist requires "No console.logs or commented out code." This PR introduces four console.error calls across the server action functions (lines 55, 100, 135, and 184). These should be removed before merging.
This same pattern also appears at:
src/lib/accountRequests.ts:100(getAccountRequests)src/lib/accountRequests.ts:135(deleteAccountRequest)src/lib/accountRequests.ts:184(acceptAccountRequest)
| console.error("Error requesting new account:", error.body); | |
| } catch (error) { | |
| return { |
| useEffect(() => { | ||
| if (isError) { | ||
| toast.error("Error", { | ||
| description: `Failed to fetch account requests: ${JSON.stringify(error)}`, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| if (data && !data.success && data.error) { | ||
| toast.error("Failed to Fetch Account Requests", { | ||
| description: data.error, | ||
| }); | ||
| } | ||
| }, [data, error, isError]); |
There was a problem hiding this comment.
Error toast will re-fire on every query invalidation
The useEffect depends on [data, error, isError]. When a user successfully accepts or declines a request, queryClient.invalidateQueries is called, which triggers a refetch of getAccountRequests. If the refetch returns the same { success: false, error: "..." } result, data will be a new object reference, causing this effect to run again and display a duplicate toast.
A more reliable pattern would be to use the onError / onSettled callbacks directly in the useQuery options, or guard with a useRef to track whether the toast has already been shown for a given error:
const hasShownErrorToast = useRef(false);
useEffect(() => {
if (isError && !hasShownErrorToast.current) {
hasShownErrorToast.current = true;
toast.error("Error", {
description: `Failed to fetch account requests: ${JSON.stringify(error)}`,
});
return;
}
if (data && !data.success && data.error && !hasShownErrorToast.current) {
hasShownErrorToast.current = true;
toast.error("Failed to Fetch Account Requests", { description: data.error });
}
}, [data, error, isError]);
Closes #77
Connected request new account frontend and view/accept/decline requests frontend to their SDK methods by updating
accountRequests.tsto use the SDK methods rather than placeholders, and updating the frontend to properly use the functions inaccountRequests.ts, so requesting new accounts and accepting/declining requests works end to end.Depends on GTBitsOfGood/juno-sdk#73 and GTBitsOfGood/juno#245 being merged first.
Video Demo of both accepting and declining new account requests:
Screen.Recording.2026-03-09.at.2.44.12.AM.mov