feat: hide rewards wallet on non-pinta flow#735
feat: hide rewards wallet on non-pinta flow#735jjramirezn merged 6 commits intopeanut-wallet-devfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request updates three components to refine wallet handling logic. The FlowHeader now takes an optional Changes
Possibly related PRs
Suggested reviewers
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (3)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/components/Payment/PaymentForm/index.tsx (1)
458-467: Well-implemented auto-selection for rewards wallet.The new effect correctly implements auto-selection of the rewards wallet when the token symbol is "PNT". This aligns with the PR objective to implement auto-selection for the pinta wallet.
Consider adding a comment to explain why this auto-selection specifically happens for "PNT" tokens for better code documentation.
// handle auto-selection of rewards wallet if token is PNT useEffect(() => { + // Auto-select rewards wallet for PNT tokens as they're specifically handled by the rewards wallet if (token?.symbol === 'PNT' && wallets) { const rewardsWallet = wallets.find((wallet) => wallet.walletProviderType === WalletProviderType.REWARDS) if (rewardsWallet) { dispatch(walletActions.setSelectedWalletId(rewardsWallet.id)) } } }, [token?.symbol, wallets, dispatch])
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/components/Global/FlowHeader/index.tsx(3 hunks)src/components/Global/WalletHeader/index.tsx(4 hunks)src/components/Payment/PaymentForm/index.tsx(3 hunks)
🔇 Additional comments (15)
src/components/Global/FlowHeader/index.tsx (5)
2-2: Good import addition for route-based logic.The addition of
usePathnameis appropriate for determining the current route to conditionally hide the rewards wallet.
11-11: Proper interface extension with optional property.Adding
isPintaReqas an optional boolean property to the interface is the right approach.
19-19: LGTM: Default value for optional prop.Setting a default value of
falsefor the optionalisPintaReqprop ensures backward compatibility.
21-25: Well-structured route detection and flag computation.Good approach to check specific routes and compute
hideRewardsWalletbased on both route and theisPintaReqflag. This implementation enables context-aware wallet visibility.
35-39: Clear prop passing with conditional flag.The updated WalletHeader component now receives the
hideRewardsWalletflag while maintaining other properties. This change connects the routing logic with the wallet display logic effectively.src/components/Payment/PaymentForm/index.tsx (4)
14-14: Appropriate import for wallet provider types.Adding
WalletProviderTypeimport is necessary for the wallet auto-selection feature.
19-19: Added necessary import for wallet actions.The
walletActionsimport is required for dispatching the wallet selection action in the new effect.
40-40: Enhanced hook usage with wallets array.Good addition of
walletsto the destructured properties fromuseWallet()to support the auto-selection feature.
471-471: Properly passing conditional flag to FlowHeader.Using
isPintaReq={token?.symbol === 'PNT'}passes the correct flag to control rewards wallet visibility in the flow header.src/components/Global/WalletHeader/index.tsx (6)
27-27: Interface properly updated with new flag.The removal of unused props and addition of
hideRewardsWalletkeeps the interface clean and focused.
132-132: Function signature correctly updated with default value.Setting
hideRewardsWallet = falseas a default makes this change backward compatible.
139-145: Effective wallet filtering implementation.The filtering logic for hiding rewards wallet when
hideRewardsWalletis true is clear and concise. The conditional check is applied before other filtering criteria, maintaining proper control flow.
146-146: Dependencies properly updated for memoization.Adding
hideRewardsWalletto the dependency array ensures the memoized value recalculates when the prop changes.
172-172: Modal closing behavior added for better UX.Adding
setShowModal(false)after wallet selection improves the user experience by closing the wallet selection modal when a wallet is selected. This addresses one of the PR objectives to close the wallet header during wallet selection.
279-279: Improved code maintainability with direct function call.Replacing prop-based connection state with a direct call to
isWalletConnectedremoves prop drilling and improves code maintainability.
| if (isExternalWallet && !isConnected) { | ||
| setShowConfirmationModal(true) | ||
| // if there's already a connected external wallet, show confirmation modal | ||
| if (hasConnectedExternalWallets) { |
There was a problem hiding this comment.
this condition fixes TASK-9401, where confirmation modal was being shown even when there were no connected external wallets
Summary by CodeRabbit
isPintaReqcontext.