Skip to content
Open
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
19 changes: 19 additions & 0 deletions src/lib/bounties.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { formatBountyPayout } from "./bounties";

describe("formatBountyPayout", () => {
it("keeps USD-only bounties unchanged", () => {
expect(formatBountyPayout(1, null)).toBe("$1 USD");
expect(formatBountyPayout("12.5", undefined)).toBe("$12.5 USD");
});

it("makes coin-paid USD bounties unambiguous", () => {
expect(formatBountyPayout(1, "SOL")).toBe(
"$1 USD value, paid in SOL equivalent"
);
});

it("ignores blank payment coin values", () => {
expect(formatBountyPayout(5, " ")).toBe("$5 USD");
});
});
6 changes: 4 additions & 2 deletions src/lib/bounties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { formatCurrency } from "@/lib/utils";

/**
* Human label for a bounty payout, matching the gig card style:
* "$2.00 USD (paid in SOL)" when a coin is set, otherwise "$2.00 USD".
* "$2.00 USD value, paid in SOL equivalent" when a coin is set,
* otherwise "$2.00 USD".
* Centralized so browse/detail/dashboard stay consistent.
*/
Comment on lines 4 to 9
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 The JSDoc comment still says "matching the gig card style", but GigCard.tsx still uses the old (paid in ${coin}) format — bounties now intentionally diverge from it. The comment should reflect this. The example amount also shows $2.00 USD with a forced two-decimal format, but formatCurrency uses minimumFractionDigits: 0, so a round number like $2 renders as $2 USD, not $2.00 USD.

Suggested change
/**
* Human label for a bounty payout, matching the gig card style:
* "$2.00 USD (paid in SOL)" when a coin is set, otherwise "$2.00 USD".
* "$2.00 USD value, paid in SOL equivalent" when a coin is set,
* otherwise "$2.00 USD".
* Centralized so browse/detail/dashboard stay consistent.
*/
/**
* Human label for a bounty payout:
* "$2 USD value, paid in SOL equivalent" when a coin is set,
* otherwise "$2 USD".
* Centralized so browse/detail/dashboard stay consistent.
*/

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

export function formatBountyPayout(
Expand All @@ -12,7 +13,8 @@ export function formatBountyPayout(
): string {
const amount = Number(amountUsd);
const usd = `${formatCurrency(amount)} USD`;
return paymentCoin ? `${usd} (paid in ${paymentCoin})` : usd;
const coin = paymentCoin?.trim();
return coin ? `${usd} value, paid in ${coin} equivalent` : usd;
}

export const questionSchema = z.object({
Expand Down
Loading