Skip to content
Open
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
16 changes: 14 additions & 2 deletions components/Bounty/lib/bountyUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,18 @@ export const isFoundationBounty = (bounty: Bounty): boolean => {
return creatorUserId === FOUNDATION_USER_ID;
};

/**
* Gets the RSC amount from a bounty, preferring totalAmount if it's greater than 0.
* This handles the case where totalAmount might be '0' due to ignoreBaseAmount transformation.
*
* @param bounty The bounty to get the amount from
* @returns The RSC amount as a number
*/
const getRscAmount = (bounty: Bounty): number => {
const totalAmount = Number.parseFloat(bounty.totalAmount || '0');
return totalAmount > 0 ? totalAmount : Number.parseFloat(bounty.amount || '0');
};

/**
* Calculates the display amount for a bounty in USD.
* For Foundation bounties, returns a flat $150 USD.
Expand All @@ -543,7 +555,7 @@ export const calculateBountyDisplayAmountUSD = (bounty: Bounty, exchangeRate: nu
return FOUNDATION_BOUNTY_FLAT_USD;
}

const rscAmount = parseFloat(bounty.totalAmount || bounty.amount || '0');
const rscAmount = getRscAmount(bounty);
return Math.round(rscAmount * exchangeRate);
};

Expand Down Expand Up @@ -571,7 +583,7 @@ export const getBountyDisplayAmount = (
showUSD: boolean
): { amount: number; isFoundation: boolean } => {
const isFoundation = isFoundationBounty(bounty);
const rscAmount = parseFloat(bounty.totalAmount || bounty.amount || '0');
const rscAmount = getRscAmount(bounty);

if (isFoundation) {
if (showUSD) {
Expand Down