feat(ui): add dynamic amount currency prefix, normalize fiat symbols, and simplify data source badge
This commit is contained in:
38
lib/currency-display.ts
Normal file
38
lib/currency-display.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { AssetType } from "@/lib/assets";
|
||||
|
||||
interface DisplayAsset {
|
||||
code: string;
|
||||
type: AssetType;
|
||||
symbol?: string;
|
||||
}
|
||||
|
||||
const FIAT_DISPLAY_SYMBOLS: Record<string, string> = {
|
||||
USD: "$",
|
||||
EUR: "€",
|
||||
GBP: "£",
|
||||
JPY: "¥",
|
||||
PLN: "zł",
|
||||
CHF: "CHF",
|
||||
CAD: "C$",
|
||||
AUD: "A$",
|
||||
NZD: "NZ$",
|
||||
CNY: "¥",
|
||||
INR: "₹",
|
||||
KRW: "₩",
|
||||
TRY: "₺",
|
||||
BRL: "R$",
|
||||
MXN: "MX$",
|
||||
THB: "฿"
|
||||
};
|
||||
|
||||
export function getDisplaySymbol(asset?: DisplayAsset): string | undefined {
|
||||
if (!asset) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (asset.type === "fiat") {
|
||||
return FIAT_DISPLAY_SYMBOLS[asset.code] ?? asset.symbol ?? asset.code;
|
||||
}
|
||||
|
||||
return asset.symbol ?? asset.code;
|
||||
}
|
||||
Reference in New Issue
Block a user