-
Notifications
You must be signed in to change notification settings - Fork 13
Chore/ethlatam perk #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore/ethlatam perk #1412
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -573,9 +573,23 @@ export const TransactionDetailsReceipt = ({ | |
| <span className="font-semibold text-gray-900">Eligible for a Peanut Perk!</span> | ||
| <span className="text-sm text-gray-600"> | ||
| {(() => { | ||
| const percentage = transaction.extraDataForDrawer.perk.discountPercentage | ||
| const amount = transaction.extraDataForDrawer.perk.amountSponsored | ||
| const amountStr = amount ? `$${amount.toFixed(2)}` : '' | ||
| const perk = transaction.extraDataForDrawer.perk | ||
| const percentage = perk.discountPercentage | ||
| const amount = perk.amountSponsored | ||
| const isCapped = perk.isCapped | ||
| const campaignCap = perk.campaignCapUsd | ||
|
|
||
| // If user hit their campaign cap, show special message | ||
| if (isCapped && campaignCap) { | ||
| if (amount !== undefined && amount !== null) { | ||
| return `$${amount.toFixed(2)} cashback — campaign limit reached! 🎉` | ||
| } | ||
| return `Campaign limit reached! 🎉` | ||
| } | ||
|
|
||
| // For non-capped messages, use amountStr | ||
| const amountStr = | ||
| amount !== undefined && amount !== null ? `$${amount.toFixed(2)}` : '' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Inconsistent Truthiness Breaks Zero Amount DisplayThe conditions checking |
||
|
|
||
| if (percentage === 100) { | ||
| return `You received a full refund${amount ? ` (${amountStr})` : ''} as a Peanut Perk.` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Handling undefined sponsorship amount at cap
When
isCappedis true butamountSponsoredis undefined,amountStrwill 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 whereamountSponsoredmight be undefined when the cap is reached, either by providing a fallback value or restructuring the message.