From 8aa6535c53e3e401068dc79fb56cb9dbc8d9bc95 Mon Sep 17 00:00:00 2001 From: qingfeng312 Date: Fri, 5 Jun 2026 10:22:05 +0800 Subject: [PATCH] fix: clarify coin-paid bounty payout labels --- src/lib/bounties.test.ts | 19 +++++++++++++++++++ src/lib/bounties.ts | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/lib/bounties.test.ts diff --git a/src/lib/bounties.test.ts b/src/lib/bounties.test.ts new file mode 100644 index 00000000..6f34fd7f --- /dev/null +++ b/src/lib/bounties.test.ts @@ -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"); + }); +}); diff --git a/src/lib/bounties.ts b/src/lib/bounties.ts index 1a2cd966..cc2ab5aa 100644 --- a/src/lib/bounties.ts +++ b/src/lib/bounties.ts @@ -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. */ export function formatBountyPayout( @@ -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({