Skip to content

feat: hide rewards wallet on non-pinta flow#735

Merged
jjramirezn merged 6 commits intopeanut-wallet-devfrom
feat/rewards-wallet
Mar 12, 2025
Merged

feat: hide rewards wallet on non-pinta flow#735
jjramirezn merged 6 commits intopeanut-wallet-devfrom
feat/rewards-wallet

Conversation

@kushagrasarathe
Copy link
Copy Markdown
Contributor

@kushagrasarathe kushagrasarathe commented Mar 12, 2025

  • contributes to TASK-9504 : hide rewards wallet on other flows
  • contributes to TASK-9284 : close wallet header on wallet selction
  • contributes to TASK-9349 : auto select pinta wallet

Summary by CodeRabbit

  • New Features
    • Enhanced wallet display: Wallet headers now dynamically adjust rewards visibility based on the current page and the new isPintaReq context.
    • Streamlined payment experience: For "PNT" tokens, the system automatically selects the appropriate rewards wallet.
    • Improved wallet selection: The wallet modal now automatically closes after a wallet is chosen.
    • Updated external link for the partner location in the rewards modal.
    • New visual representation for the partner location in the wallet card.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
peanut-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 6:56pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request updates three components to refine wallet handling logic. The FlowHeader now takes an optional isPintaReq prop and uses the current pathname to compute a new flag, hideRewardsWallet, which is then passed down. The WalletHeader component no longer uses its previous props for connection state; instead, it accepts the hideRewardsWallet flag to filter out rewards wallets and update wallet selection behavior. The PaymentForm component adds an automatic rewards wallet selection feature when the token symbol is "PNT" and passes the isPintaReq flag to the FlowHeader.

Changes

File(s) Change Summary
src/components/Global/FlowHeader/index.tsx Added optional isPintaReq prop; imported and used usePathname to determine current page; computed hideRewardsWallet based on pathname checks and isPintaReq, then passed it to WalletHeader.
src/components/Global/WalletHeader/index.tsx (and related WalletEntryCard) Removed isConnected and isUsable props; added hideRewardsWallet prop with default false; updated wallet filtering logic in sortedWallets and modified handleWalletSelection.
src/components/Payment/PaymentForm/index.tsx Enhanced wallet selection for token "PNT": imported WalletProviderType, extended useWallet to include wallets, and added a useEffect to auto-select a rewards wallet; passed new isPintaReq prop to FlowHeader.
src/components/Global/RewardsModal/index.tsx Updated href in PartnerBarLocation from placeholder to a specific URL.
src/components/Home/WalletCard.tsx Replaced Link component with a span containing PartnerBarLocation, modifying interaction from clickable to non-clickable.

Possibly related PRs

Suggested reviewers

  • jjramirezn

Poem

I'm a rabbit in a code-filled land,
Hopping through changes, oh so grand.
isPintaReq and wallets align,
Rewards hidden, all by design.
Code carrots crunch with a joyful hand!
🐇🥕✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26b0081 and 9fcdb6c.

📒 Files selected for processing (2)
  • src/components/Global/RewardsModal/index.tsx (1 hunks)
  • src/components/Home/WalletCard.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Deploy-Preview
  • GitHub Check: test
🔇 Additional comments (3)
src/components/Global/RewardsModal/index.tsx (1)

26-32: Updated placeholder to actual location link

The link has been updated from a generic placeholder to a specific Google Maps location, which improves user experience by providing direct navigation to the partner bar location.

src/components/Home/WalletCard.tsx (2)

17-17: Added import for PartnerBarLocation component

Good job importing the PartnerBarLocation component from RewardsModal to maintain consistent location linking throughout the application.


300-302: Improved event handling for partner bar link

The implementation now prevents event propagation when clicking the partner bar link. This ensures that clicking the link won't trigger the parent card's onClick event, providing a better user experience by preventing unintended navigation.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@notion-workspace
Copy link
Copy Markdown

@notion-workspace
Copy link
Copy Markdown

@notion-workspace
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b06628f and 1002142.

📒 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 usePathname is appropriate for determining the current route to conditionally hide the rewards wallet.


11-11: Proper interface extension with optional property.

Adding isPintaReq as an optional boolean property to the interface is the right approach.


19-19: LGTM: Default value for optional prop.

Setting a default value of false for the optional isPintaReq prop ensures backward compatibility.


21-25: Well-structured route detection and flag computation.

Good approach to check specific routes and compute hideRewardsWallet based on both route and the isPintaReq flag. This implementation enables context-aware wallet visibility.


35-39: Clear prop passing with conditional flag.

The updated WalletHeader component now receives the hideRewardsWallet flag 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 WalletProviderType import is necessary for the wallet auto-selection feature.


19-19: Added necessary import for wallet actions.

The walletActions import is required for dispatching the wallet selection action in the new effect.


40-40: Enhanced hook usage with wallets array.

Good addition of wallets to the destructured properties from useWallet() 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 hideRewardsWallet keeps the interface clean and focused.


132-132: Function signature correctly updated with default value.

Setting hideRewardsWallet = false as a default makes this change backward compatible.


139-145: Effective wallet filtering implementation.

The filtering logic for hiding rewards wallet when hideRewardsWallet is 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 hideRewardsWallet to 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 isWalletConnected removes prop drilling and improves code maintainability.

if (isExternalWallet && !isConnected) {
setShowConfirmationModal(true)
// if there's already a connected external wallet, show confirmation modal
if (hasConnectedExternalWallets) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition fixes TASK-9401, where confirmation modal was being shown even when there were no connected external wallets

@jjramirezn jjramirezn merged commit 5e38d9b into peanut-wallet-dev Mar 12, 2025
5 checks passed
@jjramirezn jjramirezn deleted the feat/rewards-wallet branch March 12, 2025 19:25
@coderabbitai coderabbitai bot mentioned this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants