From 7f0da3d0b2e6b0285110e2b794caeb075315e4bb Mon Sep 17 00:00:00 2001 From: Pham Quang Hoa Date: Sat, 9 May 2026 12:16:28 +0700 Subject: [PATCH] fix(usage): add extensible CURRENCY_SYMBOLS mapping for deepseek currencies --- .../usage/components/ProviderLimits/index.tsx | 13 ++++++++++++- .../usage/components/ProviderLimits/utils.tsx | 12 +++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.tsx b/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.tsx index 8f894e8a11..b7c638e28c 100644 --- a/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.tsx +++ b/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.tsx @@ -45,6 +45,17 @@ const PROVIDER_CONFIG = { deepseek: { label: "DeepSeek", color: "#4D6BFE" }, }; +// Currency symbol mapping +const CURRENCY_SYMBOLS: Record = { + USD: "$", + CNY: "¥", + EUR: "€", + GBP: "£", + JPY: "¥", + KRW: "₩", + INR: "₹", +}; + const TIER_FILTERS = [ { key: "all", labelKey: "tierAll" }, { key: "enterprise", labelKey: "tierEnterprise" }, @@ -644,7 +655,7 @@ export default function ProviderLimits() { className="text-[12px] font-bold tabular-nums" style={{ color: colors.text }} > - {q.currency === "CNY" ? "¥" : q.currency === "USD" ? "$" : ""} + {CURRENCY_SYMBOLS[q.currency] ?? q.currency ?? ""} {(q.creditCount ?? q.remaining).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2, diff --git a/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx b/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx index 0a5ca5612e..7132256c4b 100644 --- a/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx +++ b/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx @@ -304,15 +304,17 @@ export function parseQuotaData(provider, data) { case "deepseek": // DeepSeek balance: credits-style display with currency - // Handles both "credits" and "credits_usd"/"credits_cny" key formats + // Match any "credits" key with optional 3-letter currency suffix if (data.quotas) { Object.entries(data.quotas).forEach(([quotaKey, quota]: [string, any]) => { - // Match credits_usd, credits_cny, or legacy credits - if (/^credits(?:_usd|_cny)?$/.test(quotaKey)) { + // Match credits, credits_usd, credits_cny, credits_eur, etc. + const match = quotaKey.match(/^credits(?:_([a-z]{3}))?$/); + if (match) { const remaining = Number(quota?.remaining ?? 0); - const currency = quota?.currency ?? (quotaKey.includes("cny") ? "CNY" : "USD"); + // Extract currency from key suffix or use quota.currency, fallback to USD + const currency = quota?.currency ?? (match[1] ? match[1].toUpperCase() : "USD"); normalizedQuotas.push({ - name: `${currency}`, + name: currency, used: 0, total: 0, remaining,