Fix missing Edit page button for brand managers on BTC+ overview#986
Fix missing Edit page button for brand managers on BTC+ overview#986akshatmittal wants to merge 2 commits into
Conversation
Deploying register-app with
|
| Latest commit: |
857e3a2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://04b108ef.register-app.pages.dev |
| Branch Preview URL: | https://codex-rca-and-pr-fix-in-regi.register-app.pages.dev |
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 2/3 reviews remaining, refill in 20 minutes. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/views/index-dtf/overview/components/yield-index/yield-index-about.tsx`:
- Around line 33-41: Replace the nested interactive elements by using the
asChild pattern: instead of putting <Button> inside <Link>, render the Link as
the button element (add asChild to Link) and keep the <Button> markup as the
child so the DOM produces a single interactive element; update the block that
uses Link, Button, ImagePlus, ROUTES.MANAGE and trackClick so the Link has
asChild and the Button becomes the rendered element while preserving the onClick
tracking call (call trackClick from Button's onClick or forward the handler to
the rendered element) and the existing props (variant, size, className,
ImagePlus, and "Edit page" text).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2e808684-32e7-4aa0-a55c-9574d117e085
📒 Files selected for processing (1)
src/views/index-dtf/overview/components/yield-index/yield-index-about.tsx
|
|
||
| return ( | ||
| <div className="p-4 sm:p-6"> | ||
| {isBrandManager && ( |
There was a problem hiding this comment.
Move the button inside the flex element for the card title and push it to the right, making [TITLE] -> [Button] layout instead of pushing the title and the rest of the elements down
Make sure it fits and it doesnt create a layout shift
|
@codex fix comments from @lcamargof |
Summary
Testing
Also completed follow-up workflow actions:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/views/index-dtf/overview/components/yield-index/yield-index-about.tsx`:
- Line 19: The inline click handler created during render should be memoized
with useCallback: locate the component (YieldIndexAbout) where const {
trackClick } = useTrackIndexDTFClick('overview', 'overview') is used and replace
the inline onClick function with a named handler created via useCallback (depend
on trackClick and any props/state used). Ensure the handler calls
trackClick(...) and is passed to the element instead of an anonymous function so
it remains stable across renders.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bf5ab349-09bf-4f6f-8ba1-092e4630f912
📒 Files selected for processing (1)
src/views/index-dtf/overview/components/yield-index/yield-index-about.tsx
| const data = useAtomValue(indexDTFAtom) | ||
| const brandData = useAtomValue(indexDTFBrandAtom) | ||
| const isBrandManager = useAtomValue(isBrandManagerAtom) | ||
| const { trackClick } = useTrackIndexDTFClick('overview', 'overview') |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="src/views/index-dtf/overview/components/yield-index/yield-index-about.tsx"
echo "Checking for inline onClick handler in ${FILE}..."
rg -nP 'onClick=\{\s*\(\)\s*=>|\bonClick=\{[^}]*=>[^}]*\}' "$FILE" -C2
echo
echo "Expected: no inline onClick arrow handlers after refactor."Repository: reserve-protocol/register
Length of output: 429
🏁 Script executed:
cat -n src/views/index-dtf/overview/components/yield-index/yield-index-about.tsx | head -70Repository: reserve-protocol/register
Length of output: 2717
🏁 Script executed:
find . -name "useTrackIndexDTFPage*" -o -name "*useTrackIndexDTFPage*"Repository: reserve-protocol/register
Length of output: 121
🏁 Script executed:
cat -n ./src/views/index-dtf/hooks/useTrackIndexDTFPage.tsRepository: reserve-protocol/register
Length of output: 2562
🏁 Script executed:
grep -n "useCallback" ./src/views/index-dtf/hooks/useTrackIndexDTFPage.tsRepository: reserve-protocol/register
Length of output: 51
🏁 Script executed:
rg -n "onClick=" ./src/views/index-dtf/overview/components/yield-index/yield-index-about.tsxRepository: reserve-protocol/register
Length of output: 130
Extract click handler with useCallback instead of inline render function.
Line 45 creates an inline handler during render. Per repo convention, memoize this callback using useCallback.
Suggested refactor
+import { useCallback } from 'react'
import { Skeleton } from '@/components/ui/skeleton'
import {
indexDTFAtom,
indexDTFBrandAtom,
isBrandManagerAtom,
} from '@/state/dtf/atoms'
@@
const brandData = useAtomValue(indexDTFBrandAtom)
const isBrandManager = useAtomValue(isBrandManagerAtom)
const { trackClick } = useTrackIndexDTFClick('overview', 'overview')
+ const handleBrandManagerClick = useCallback(() => {
+ trackClick('brand_manager')
+ }, [trackClick])
@@
<Link
to={`../${ROUTES.MANAGE}`}
- onClick={() => trackClick('brand_manager')}
+ onClick={handleBrandManagerClick}
>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/views/index-dtf/overview/components/yield-index/yield-index-about.tsx` at
line 19, The inline click handler created during render should be memoized with
useCallback: locate the component (YieldIndexAbout) where const { trackClick } =
useTrackIndexDTFClick('overview', 'overview') is used and replace the inline
onClick function with a named handler created via useCallback (depend on
trackClick and any props/state used). Ensure the handler calls trackClick(...)
and is passed to the element instead of an anonymous function so it remains
stable across renders.
Motivation
Description
src/views/index-dtf/overview/components/yield-index/yield-index-about.tsxto add the missing brand-manager gated Edit page CTA.isBrandManagerAtom,Button,ImagePlus, anduseTrackIndexDTFClick, and wireduseAtomValue(isBrandManagerAtom)plustrackClick('brand_manager')for analytics.../manageand is conditionally rendered only whenisBrandManageris true so non-brand-manager wallets remain unaffected.Testing
pnpm run typecheck(i.e.,tsc --noEmit) and it completed successfully.Codex Task
Summary by CodeRabbit
New Features
UI Improvements