Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds optional campaign cap fields to transaction perk data and updates receipt rendering to use a local Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (10)📓 Common learnings📚 Learning: 2024-10-07T15:25:45.170ZApplied to files:
📚 Learning: 2025-10-29T11:27:59.248ZApplied to files:
📚 Learning: 2025-09-18T09:30:42.901ZApplied to files:
📚 Learning: 2024-10-07T15:28:25.280ZApplied to files:
📚 Learning: 2024-12-11T10:13:22.806ZApplied to files:
📚 Learning: 2024-10-29T12:20:47.207ZApplied to files:
📚 Learning: 2025-08-26T15:25:53.328ZApplied to files:
📚 Learning: 2024-10-08T20:13:42.967ZApplied to files:
📚 Learning: 2024-10-08T20:13:42.967ZApplied to files:
⏰ 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)
🔇 Additional comments (2)
Comment |
There was a problem hiding this comment.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on December 5
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| // If user hit their campaign cap, show special message | ||
| if (isCapped && campaignCap) { | ||
| return `You received ${amountStr} cashback! You've reached your $${campaignCap.toFixed(0)} campaign limit for now 🎉` | ||
| } |
There was a problem hiding this comment.
Bug: Handling undefined sponsorship amount at cap
When isCapped is true but amountSponsored is undefined, amountStr will be an empty string. This results in a malformed message: "You received cashback!" with an awkward double space instead of showing the amount. The code should handle the case where amountSponsored might be undefined when the cap is reached, either by providing a fallback value or restructuring the message.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/components/TransactionDetails/TransactionDetailsReceipt.tsx (1)
581-581: Note:remainingCapUsdis extracted but unused.The field
remainingCapUsdis added to the perk type but isn't used in the UI. This is likely intentional for future functionality (e.g., showing how much of the campaign cap remains). If not needed immediately, consider documenting this for future reference.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/TransactionDetails/TransactionDetailsReceipt.tsx(1 hunks)src/components/TransactionDetails/transactionTransformer.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 942
File: src/components/AddMoney/consts/index.ts:2151-2162
Timestamp: 2025-06-30T10:44:08.048Z
Learning: Hugo0 often agrees with refactoring suggestions but defers implementation due to time constraints, preferring to track improvements as follow-up issues when they're part of larger architectural changes.
⏰ 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 (1)
src/components/TransactionDetails/transactionTransformer.ts (1)
79-81: LGTM! Clean additive changes.The three new optional fields (
isCapped,campaignCapUsd,remainingCapUsd) are properly typed and consistently added in both the interface definition and the mapping logic. The optional nature of these fields ensures backward compatibility.Also applies to: 530-532
|
|
||
| // For non-capped messages, use amountStr | ||
| const amountStr = | ||
| amount !== undefined && amount !== null ? `$${amount.toFixed(2)}` : '' |
There was a problem hiding this comment.
Bug: Inconsistent Truthiness Breaks Zero Amount Display
The conditions checking amount ? on lines 596, 598, and 600 are inconsistent with the amountStr definition on line 593. When amount is 0, amountStr will be "$0.00" but the truthy check amount ? evaluates to false, preventing the amount from being displayed. This creates a mismatch where zero-value perks won't show their amount even though the string is properly formatted.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/components/TransactionDetails/TransactionDetailsReceipt.tsx (1)
583-589: Consider refining the capped message phrasing.The current message structure places two celebratory statements back-to-back: "You received $X cashback! You've reached your $Y campaign limit 🎉". The double-exclamation creates slightly awkward phrasing.
Consider one of these alternatives:
const amountText = amount !== undefined && amount !== null - ? `You received $${amount.toFixed(2)} cashback! ` + ? `You received $${amount.toFixed(2)} cashback. ` : '' -return `${amountText}You've reached your $${campaignCap.toFixed(0)} campaign limit 🎉` +return `${amountText}You've reached your $${campaignCap.toFixed(0)} campaign limit for now 🎉`Or restructure to a single cohesive message:
-const amountText = - amount !== undefined && amount !== null - ? `You received $${amount.toFixed(2)} cashback! ` - : '' -return `${amountText}You've reached your $${campaignCap.toFixed(0)} campaign limit for now 🎉` +if (amount !== undefined && amount !== null) { + return `You received $${amount.toFixed(2)} cashback and reached your $${campaignCap.toFixed(0)} campaign limit 🎉` +} else { + return `You've reached your $${campaignCap.toFixed(0)} campaign limit 🎉` +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/TransactionDetails/TransactionDetailsReceipt.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 942
File: src/components/AddMoney/consts/index.ts:2151-2162
Timestamp: 2025-06-30T10:44:08.048Z
Learning: Hugo0 often agrees with refactoring suggestions but defers implementation due to time constraints, preferring to track improvements as follow-up issues when they're part of larger architectural changes.
📚 Learning: 2024-12-11T10:13:22.806Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 564
File: src/components/Request/Pay/Views/Initial.view.tsx:430-430
Timestamp: 2024-12-11T10:13:22.806Z
Learning: In the React TypeScript file `src/components/Request/Pay/Views/Initial.view.tsx`, when reviewing the `InitialView` component, do not flag potential issues with using non-null assertion `!` on the `slippagePercentage` variable, as handling undefined values in this context is considered out of scope.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
📚 Learning: 2024-10-29T12:20:47.207Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 495
File: src/components/Create/Link/Input.view.tsx:244-248
Timestamp: 2024-10-29T12:20:47.207Z
Learning: In the `TokenAmountInput` component within `src/components/Global/TokenAmountInput/index.tsx`, when `balance` is undefined, the `maxValue` prop should be set to an empty string `''`.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
📚 Learning: 2025-10-29T11:27:59.248Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1368
File: src/components/Common/ActionList.tsx:109-111
Timestamp: 2025-10-29T11:27:59.248Z
Learning: In `src/components/Common/ActionList.tsx`, the `balance` from `useWallet()` hook is always in USDC (as a formatted string), making it directly comparable to USD amounts without conversion. The comparison `Number(balance) >= amountInUsd` is intentional and correct.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
📚 Learning: 2024-10-08T20:13:42.967Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 413
File: src/components/Request/Pay/Views/Initial.view.tsx:71-72
Timestamp: 2024-10-08T20:13:42.967Z
Learning: In `src/components/Request/Pay/Views/Initial.view.tsx`, it's acceptable to use the `!` operator in TypeScript to assert that `selectedTokenData` is not `null` or `undefined`, and potential runtime errors from accessing its properties without checks can be disregarded.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1230
File: src/app/(mobile-ui)/withdraw/page.tsx:92-97
Timestamp: 2025-09-18T09:30:42.901Z
Learning: In src/app/(mobile-ui)/withdraw/page.tsx, the useEffect that calls setShowAllWithdrawMethods(true) when amountFromContext exists is intentionally designed to run only on component mount (empty dependency array), not when amountFromContext changes. This is the correct behavior for the withdraw flow where showing all methods should only happen on initial load when an amount is already present.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
📚 Learning: 2025-08-26T15:25:53.328Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1132
File: src/app/[...recipient]/client.tsx:394-397
Timestamp: 2025-08-26T15:25:53.328Z
Learning: In `src/components/Common/ActionListDaimoPayButton.tsx`, the `handleCompleteDaimoPayment` function should not display error messages to users when DB update fails because the Daimo payment itself has succeeded - showing errors would be confusing since the payment was successful.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
📚 Learning: 2025-07-07T20:22:11.092Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 958
File: src/app/actions/tokens.ts:266-266
Timestamp: 2025-07-07T20:22:11.092Z
Learning: In `src/app/actions/tokens.ts`, within the `fetchWalletBalances` function, using the non-null assertion operator `!` on `process.env.MOBULA_API_KEY!` is intentional and correct, and should not be flagged for replacement with explicit validation.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
📚 Learning: 2024-10-08T20:13:42.967Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Pay.tsx:103-111
Timestamp: 2024-10-08T20:13:42.967Z
Learning: When the token price cannot be fetched in `src/components/Request/Pay/Pay.tsx` within the `PayRequestLink` component, set `tokenPriceData.price` to 0 to ensure the UI remains functional. Since Squid uses their own price engine for x-chain fulfillment transactions, this approach will not affect the transaction computation.
Applied to files:
src/components/TransactionDetails/TransactionDetailsReceipt.tsx
⏰ 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). (2)
- GitHub Check: Cursor Bugbot
- GitHub Check: Deploy-Preview
🔇 Additional comments (2)
src/components/TransactionDetails/TransactionDetailsReceipt.tsx (2)
576-580: Verify that perk properties are always defined.The code extracts
discountPercentage,amountSponsored,isCapped, andcampaignCapUsdfrom the perk object without null checks. While the parent conditional ensuresperk.claimedexists, it doesn't guarantee these new optional fields are present. Ifpercentageis undefined, lines 595-601 will produce malformed messages like "You received undefined% cashback...".Add defensive checks or fallback values for these properties:
const perk = transaction.extraDataForDrawer.perk -const percentage = perk.discountPercentage -const amount = perk.amountSponsored -const isCapped = perk.isCapped -const campaignCap = perk.campaignCapUsd +const percentage = perk.discountPercentage ?? 0 +const amount = perk.amountSponsored +const isCapped = perk.isCapped ?? false +const campaignCap = perk.campaignCapUsdOr add an early return if required fields are missing:
const perk = transaction.extraDataForDrawer.perk if (!perk.discountPercentage) return 'Perk details unavailable' const percentage = perk.discountPercentage // ... rest of code
585-586: Good handling of undefined amount.The explicit checks for
amount !== undefined && amount !== nullproperly address the previous review concern about malformed messages when amount is missing. This ensures the message remains clear whether or not the amount is available.
only the perk related changes are relevant. rest are pulls from prod/
Note
Show campaign-cap reached messaging in the perk banner and plumb cap fields through the transaction transformer.
src/components/TransactionDetails/TransactionDetailsReceipt.tsxto handle capped campaigns usingperk.isCappedandperk.campaignCapUsd, showing a “campaign limit reached” message and safe amount formatting.extraDataForDrawer.perkinsrc/components/TransactionDetails/transactionTransformer.tswithisCapped,campaignCapUsd, andremainingCapUsdand propagate these fields when mappingentry.extraData.perk.Written by Cursor Bugbot for commit 880dfea. This will update automatically on new commits. Configure here.