Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/components/TransactionDetails/TransactionDetailsReceipt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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! 🎉`
}
Copy link
Copy Markdown

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 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.

Fix in Cursor Fix in Web


// For non-capped messages, use amountStr
const amountStr =
amount !== undefined && amount !== null ? `$${amount.toFixed(2)}` : ''
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web


if (percentage === 100) {
return `You received a full refund${amount ? ` (${amountStr})` : ''} as a Peanut Perk.`
Expand Down
6 changes: 6 additions & 0 deletions src/components/TransactionDetails/transactionTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export interface TransactionDetails {
merchantInfo?: {
promoDescription?: string
}
isCapped?: boolean
campaignCapUsd?: number
remainingCapUsd?: number
}
depositInstructions?: {
amount: string
Expand Down Expand Up @@ -524,6 +527,9 @@ export function mapTransactionDataForDrawer(entry: HistoryEntry): MappedTransact
amountSponsored?: number
txHash?: string
merchantInfo?: { promoDescription?: string }
isCapped?: boolean
campaignCapUsd?: number
remainingCapUsd?: number
}
| undefined,
depositInstructions:
Expand Down
Loading