feat(ui): 添加 Big.js 格式化工具,优化表格数字精度展示
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { getAssets } from '@/actions/asset';
|
||||
import { getTransactions } from '@/actions/transaction';
|
||||
import { AddTransactionDialog } from '@/components/transactions/add-transaction-dialog';
|
||||
import { formatAmount, formatQuantity } from '@/lib/formatters';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -25,7 +26,7 @@ export default async function TransactionsPage() {
|
||||
FEE: '手续费',
|
||||
};
|
||||
|
||||
const assetMap = new Map(assets.map((a) => [a.id, a.symbol]));
|
||||
const assetMap = new Map(assets.map((a) => [a.id, { symbol: a.symbol, type: a.type }]));
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -62,14 +63,16 @@ export default async function TransactionsPage() {
|
||||
</TableRow>
|
||||
) : (
|
||||
transactions.map((tx) => {
|
||||
const symbol = assetMap.get(tx.assetId) || tx.assetId;
|
||||
const assetInfo = assetMap.get(tx.assetId);
|
||||
const symbol = assetInfo?.symbol || tx.assetId;
|
||||
const assetType = assetInfo?.type || 'CASH';
|
||||
return (
|
||||
<TableRow key={tx.id}>
|
||||
<TableCell className="font-medium">{symbol}</TableCell>
|
||||
<TableCell>{typeLabels[tx.txType] || tx.txType}</TableCell>
|
||||
<TableCell>{tx.quantity}</TableCell>
|
||||
<TableCell>{tx.price}</TableCell>
|
||||
<TableCell>{tx.fee}</TableCell>
|
||||
<TableCell>{formatQuantity(tx.quantity, assetType)}</TableCell>
|
||||
<TableCell>{formatAmount(tx.price)}</TableCell>
|
||||
<TableCell>{formatAmount(tx.fee)}</TableCell>
|
||||
<TableCell>{tx.txCurrency}</TableCell>
|
||||
<TableCell>
|
||||
{tx.executedAt
|
||||
|
||||
Reference in New Issue
Block a user