fix(usage): add extensible CURRENCY_SYMBOLS mapping for deepseek currencies

This commit is contained in:
Pham Quang Hoa
2026-05-09 12:16:28 +07:00
committed by diegosouzapw
parent 75008d8098
commit 7f0da3d0b2
2 changed files with 19 additions and 6 deletions

View File

@@ -45,6 +45,17 @@ const PROVIDER_CONFIG = {
deepseek: { label: "DeepSeek", color: "#4D6BFE" },
};
// Currency symbol mapping
const CURRENCY_SYMBOLS: Record<string, string> = {
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,

View File

@@ -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,