mirror of
https://github.com/Zproger/Aurum.git
synced 2026-11-18 08:02:49 +07:00
fix: копеечные цены крипты не округлялись в $0
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Cell, Pie, PieChart, ResponsiveContainer, Tooltip } from "recharts";
|
||||
import { formatCurrency, maskAmount } from "@/lib/format";
|
||||
import { formatCryptoAmount, maskAmount } from "@/lib/format";
|
||||
import { useTranslation } from "@/lib/i18n";
|
||||
import type { CryptoHolding } from "@/types";
|
||||
|
||||
@@ -65,7 +65,7 @@ function DonutTooltip({
|
||||
<div className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm shadow-md">
|
||||
<p className="font-medium text-text-primary">{slice.key === "other" ? otherLabel : slice.name}</p>
|
||||
<p className="text-text-muted">
|
||||
{maskAmount(formatCurrency(slice.amount), hidden)} · {slice.percent.toFixed(1)}%
|
||||
{maskAmount(formatCryptoAmount(slice.amount), hidden)} · {slice.percent.toFixed(1)}%
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
@@ -132,7 +132,7 @@ export function CryptoAllocationBody({ holdings, isLoading, hidden }: CryptoAllo
|
||||
<td className="py-1.5 pr-3 text-right font-medium tabular-nums text-text-primary">
|
||||
{slice.percent.toFixed(1)}%
|
||||
</td>
|
||||
<td className="py-1.5 text-right tabular-nums text-text-muted">{maskAmount(formatCurrency(slice.amount), hidden)}</td>
|
||||
<td className="py-1.5 text-right tabular-nums text-text-muted">{maskAmount(formatCryptoAmount(slice.amount), hidden)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Bitcoin, Plus, Trash2 } from "lucide-react";
|
||||
import { formatCurrency, maskAmount } from "@/lib/format";
|
||||
import { formatCryptoAmount, maskAmount } from "@/lib/format";
|
||||
import { useTranslation } from "@/lib/i18n";
|
||||
import type { CryptoHolding, CryptoPortfolio } from "@/types";
|
||||
|
||||
@@ -106,7 +106,7 @@ export function CryptoHoldingsTable({
|
||||
</td>
|
||||
<td className="py-3 pr-3 text-right tabular-nums text-text-primary">
|
||||
{holding.current_price !== null
|
||||
? maskAmount(formatCurrency(holding.current_price), hidden)
|
||||
? maskAmount(formatCryptoAmount(holding.current_price), hidden)
|
||||
: t("crypto.pendingPrice")}
|
||||
</td>
|
||||
<td className="py-3 pr-3 text-right">
|
||||
@@ -120,20 +120,20 @@ export function CryptoHoldingsTable({
|
||||
</td>
|
||||
<td className="py-3 pr-3 text-right">
|
||||
<span className="block tabular-nums text-text-primary">
|
||||
{holding.value !== null ? maskAmount(formatCurrency(holding.value), hidden) : t("crypto.pendingPrice")}
|
||||
{holding.value !== null ? maskAmount(formatCryptoAmount(holding.value), hidden) : t("crypto.pendingPrice")}
|
||||
</span>
|
||||
<span className="block text-xs tabular-nums text-text-muted">
|
||||
{maskAmount(`${Number(holding.quantity)} ${holding.symbol}`, hidden)}
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-3 pr-3 text-right tabular-nums text-text-primary">
|
||||
{holding.avg_buy_price !== null ? maskAmount(formatCurrency(holding.avg_buy_price), hidden) : "—"}
|
||||
{holding.avg_buy_price !== null ? maskAmount(formatCryptoAmount(holding.avg_buy_price), hidden) : "—"}
|
||||
</td>
|
||||
<td className="py-3 pr-3 text-right">
|
||||
{holding.profit_loss !== null && holding.profit_loss_percent !== null ? (
|
||||
<>
|
||||
<span className="block tabular-nums" style={{ color: profitColor }}>
|
||||
{maskAmount(`${sign}${formatCurrency(holding.profit_loss)}`, hidden)}
|
||||
{maskAmount(`${sign}${formatCryptoAmount(holding.profit_loss)}`, hidden)}
|
||||
</span>
|
||||
<span className="block text-xs tabular-nums" style={{ color: profitColor }}>
|
||||
{sign}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
import { Dialog } from "@/components/ui/Dialog";
|
||||
import { useCryptoTransactions, useDeleteCryptoTransaction } from "@/hooks/useCrypto";
|
||||
import { formatCurrency, formatTransactionDate, maskAmount } from "@/lib/format";
|
||||
import { formatCryptoAmount, formatTransactionDate, maskAmount } from "@/lib/format";
|
||||
import { useTranslation } from "@/lib/i18n";
|
||||
import type { CryptoHolding, CryptoTransaction } from "@/types";
|
||||
|
||||
@@ -47,7 +47,7 @@ export function CryptoTransactionHistoryModal({ open, onClose, holding, hidden,
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block text-sm text-text-primary">
|
||||
{maskAmount(`${Number(tx.quantity)} ${holding.symbol} · ${formatCurrency(tx.price_per_unit)}`, hidden)}
|
||||
{maskAmount(`${Number(tx.quantity)} ${holding.symbol} · ${formatCryptoAmount(tx.price_per_unit)}`, hidden)}
|
||||
</span>
|
||||
<span className="block text-xs text-text-muted">
|
||||
{formatTransactionDate(tx.date, true)}
|
||||
|
||||
Reference in New Issue
Block a user