Skip to content

[TASK-12655] Fix: hide action btns for own profile POV#1155

Merged
Zishan-7 merged 2 commits intopeanut-wallet-devfrom
fix/self-pov-profile
Sep 4, 2025
Merged

[TASK-12655] Fix: hide action btns for own profile POV#1155
Zishan-7 merged 2 commits intopeanut-wallet-devfrom
fix/self-pov-profile

Conversation

@Zishan-7
Copy link
Copy Markdown
Contributor

@Zishan-7 Zishan-7 commented Sep 1, 2025

Self Profile POV
image

Some other user profile POV

image

@notion-workspace
Copy link
Copy Markdown

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 1, 2025

Walkthrough

Updates PublicProfile to use the auth context to detect self-profiles, add an optional onSendClick prop, set isLoggedIn default to false, and render Send/Request actions only for other users. handleSend prefers onSendClick, else dispatches paymentActions.setView('INITIAL').

Changes

Cohort / File(s) Summary of changes
PublicProfile component updates
src/components/Profile/components/PublicProfile.tsx
- Import and use useAuth to obtain current user and compute isSelfProfile
- Add onSendClick?: () => void to PublicProfileProps and accept it in the component signature; set isLoggedIn default to false
- handleSend calls onSendClick() when provided, otherwise dispatches paymentActions.setView('INITIAL')
- Only render Send/Request actions when viewing another user's profile; split actions into distinct Send (button) and Request (link) with updated labels/icons

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • kushagrasarathe
  • jjramirezn

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 812e0dc and b8fa17f.

📒 Files selected for processing (1)
  • src/components/Profile/components/PublicProfile.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-13T10:05:24.057Z
Learnt from: kushagrasarathe
PR: peanutprotocol/peanut-ui#845
File: src/components/Request/link/views/Create.request.link.view.tsx:81-81
Timestamp: 2025-05-13T10:05:24.057Z
Learning: In the peanut-ui project, pages that handle request flows (like Create.request.link.view.tsx) are only accessible to logged-in users who will always have a username, making null checks for user?.user.username unnecessary in these contexts.

Applied to files:

  • src/components/Profile/components/PublicProfile.tsx
🧬 Code graph analysis (1)
src/components/Profile/components/PublicProfile.tsx (3)
src/context/authContext.tsx (1)
  • useAuth (182-188)
src/components/0_Bruddle/Button.tsx (1)
  • Button (76-267)
src/components/Global/Icons/Icon.tsx (1)
  • Icon (189-198)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (3)
src/components/Profile/components/PublicProfile.tsx (3)

24-25: New onSendClick prop looks good

The optional override is clean and the fallback to paymentActions.setView('INITIAL') keeps existing behavior.


19-19: Importing useAuth — LGTM

Required for self-POV detection.


27-27: No change needed—isLoggedIn is always passed by callers; the default value is never used.

Likely an incorrect or invalid review comment.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/self-pov-profile

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
peanut-wallet Ready Ready Preview Comment Sep 2, 2025 7:31am

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: 2

🧹 Nitpick comments (1)
src/components/Profile/components/PublicProfile.tsx (1)

45-53: Avoid shadowing user in the usersApi callback.

then((user) => { ... }) shadows the auth user above and can confuse readers. Rename to profileUser.

-        usersApi.getByUsername(username).then((user) => {
-            if (user?.fullName) setFullName(user.fullName)
-            if (user?.kycStatus === 'approved') setIsKycVerified(true)
+        usersApi.getByUsername(username).then((profileUser) => {
+            if (profileUser?.fullName) setFullName(profileUser.fullName)
+            if (profileUser?.kycStatus === 'approved') setIsKycVerified(true)
             // to check if the logged in user has sent money to the profile user,
             // we check the amount that the profile user has received from the logged in user.
-            if (user?.totalUsdReceivedFromCurrentUser) {
-                setTotalSentByLoggedInUser(user.totalUsdReceivedFromCurrentUser)
+            if (profileUser?.totalUsdReceivedFromCurrentUser) {
+                setTotalSentByLoggedInUser(profileUser.totalUsdReceivedFromCurrentUser)
             }
         })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 03c8536 and 812e0dc.

📒 Files selected for processing (1)
  • src/components/Profile/components/PublicProfile.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/Profile/components/PublicProfile.tsx (2)
src/context/authContext.tsx (1)
  • useAuth (182-188)
src/components/Global/Icons/Icon.tsx (1)
  • Icon (189-198)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (4)
src/components/Profile/components/PublicProfile.tsx (4)

36-42: Good fallback behavior for Send.

Using onSendClick when provided and falling back to paymentActions.setView('INITIAL') is a clean extension point.

Also applies to: 98-109


106-109: Icons already registered
Both arrow-up-right and arrow-down-left are imported and mapped in src/components/Global/Icons/Icon.tsx. No changes needed.


19-19: No action needed: PublicProfile is already under AuthProvider
PublicProfile is rendered in src/app/[...recipient]/client.tsx, which is nested in the root ContextProvider (wrapping AuthProvider) defined in src/app/layout.tsx.


63-83: Ignore deriving loggedIn from useAuth in PublicProfile
PublicProfile is designed to be driven solely by the isLoggedIn prop (no useAuth import exists), so adding an auth‐context dependency here would couple it unnecessarily. Rely on the existing prop-based gating.

Likely an incorrect or invalid review comment.

@Zishan-7 Zishan-7 merged commit 80dbd12 into peanut-wallet-dev Sep 4, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants