-
Notifications
You must be signed in to change notification settings - Fork 13
Peanut wallet #1641
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
Peanut wallet #1641
Changes from all commits
dba133a
d1a8f7c
b82a269
24c1242
986b45c
16fdf6f
87b5d3b
8608676
780b64a
409e1a5
c0c25c6
faed87f
2b87dd6
16816bd
b942bda
81c454f
b9f5a35
c2888c5
7523703
3fb95a9
6bb7377
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 'use client' | ||
|
|
||
| import { usePathname } from 'next/navigation' | ||
| import { notFound } from 'next/navigation' | ||
| import { IS_DEV } from '@/constants/general.consts' | ||
|
|
||
| // Routes that are allowed in production (protected by API key / user check) | ||
| const PRODUCTION_ALLOWED_ROUTES = ['/dev/full-graph', '/dev/payment-graph'] | ||
|
|
||
| export default function DevLayout({ children }: { children: React.ReactNode }) { | ||
| const pathname = usePathname() | ||
|
|
||
| // In production, only allow specific routes (full-graph, payment-graph) | ||
| // Other dev tools (leaderboard, shake-test, dev index) are dev-only | ||
| if (!IS_DEV) { | ||
| const isAllowedInProd = PRODUCTION_ALLOWED_ROUTES.some((route) => pathname?.startsWith(route)) | ||
| if (!isAllowedInProd) { | ||
| notFound() | ||
| } | ||
| } | ||
|
|
||
| return <>{children}</> | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,12 +15,20 @@ export default function DevToolsPage() { | |
| status: 'active', | ||
| }, | ||
| { | ||
| name: 'Invite Graph', | ||
| description: 'Interactive force-directed graph visualization of all user invites (admin only)', | ||
| path: '/dev/invite-graph', | ||
| name: 'Full Graph', | ||
| description: | ||
| 'Interactive force-directed graph visualization of all users, invites, and P2P activity (admin only)', | ||
| path: '/dev/full-graph', | ||
| icon: '🕸️', | ||
| status: 'active', | ||
| }, | ||
| { | ||
| name: 'Payment Graph', | ||
| description: 'P2P payment flow visualization', | ||
| path: '/dev/payment-graph', | ||
| icon: '💸', | ||
| status: 'active', | ||
| }, | ||
| { | ||
| name: 'Shake Test', | ||
| description: 'Test progressive shake animation and confetti for perk claiming', | ||
|
|
@@ -70,7 +78,7 @@ export default function DevToolsPage() { | |
| <Card className="space-y-2 bg-blue-50 p-4"> | ||
| <h3 className="font-bold text-blue-900">ℹ️ Info</h3> | ||
| <ul className="space-y-1 text-sm text-blue-800"> | ||
| <li>• These tools are publicly accessible (no login required)</li> | ||
| <li>• These tools are only available in development mode</li> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent info text with actual access control. This text states tools are "only available in development mode", but according to 🤖 Prompt for AI Agents |
||
| <li>• Perfect for testing on multiple devices</li> | ||
| <li>• Share the URL with team members for testing</li> | ||
| </ul> | ||
|
|
||
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.
🧩 Analysis chain
🌐 Web query:
Next.js notFound() client component 'use client' error behavior💡 Result:
notFound()is not a “client-side navigation” API in the App Router. It’s implemented by throwing a special error (NEXT_HTTP_ERROR_FALLBACK;404) to terminate rendering of the current route segment, so Next.js can render that segment’snot-found.jsUI. This mechanism is designed for server-side rendering paths (e.g., Server Components during render, and other server-controlled flows), not for Client Component event handlers. [1]Because
"use client"makes the file part of the client module graph (rendered on the client after navigation/hydration), callingnotFound()there typically results in a runtime error / red error overlay, rather than showingnot-found.js, since there’s no server render to “bail out of” and swap in the segment’s Not Found boundary. [1], [2]What to do in a Client Component instead
router.replace(...)) to a dedicated route, rather than callingnotFound(). (Thenot-found.jsconvention is specifically for whennotFound()is thrown during segment rendering.) [3]Note: Tutorials showing
notFound()inside a"use client"component are misleading for real App Router behavior. [1], [4]Sources:
[1] Next.js API Reference:
notFound()(throwsNEXT_HTTP_ERROR_FALLBACK;404)[2] Next.js Docs: Server vs Client Components (
"use client"boundary; Client Components render on the client)[3] Next.js API Reference:
not-found.jsconvention (rendered whennotFound()is thrown in a segment)[4] Example article demonstrating
notFound()inside a Client Component (non-official; conflicts with intended mechanism)🏁 Script executed:
Repository: peanutprotocol/peanut-ui
Length of output: 1028
notFound()throws a runtime error in client components and won't render the not-found pagenotFound()is implemented by throwing a special error during server-side rendering to bail out of a route segment. Since this file is marked with'use client', the component renders on the client after navigation, so callingnotFound()will result in a runtime error instead of showingnot-found.js. Either move this guard to a Server Component or middleware, or replace with a client-side redirect using the router.🤖 Prompt for AI Agents