feat: redesign portfolio position cards
This commit is contained in:
@@ -17,6 +17,21 @@ export function formatMoney(money: Money | null): string {
|
||||
return `${formatDecimal(money.value)} ${money.currency === "RUB" ? "₽" : money.currency}`;
|
||||
}
|
||||
|
||||
export function formatShare(
|
||||
numerator: Money | null,
|
||||
denominator: Money | null,
|
||||
): string | null {
|
||||
if (!numerator || !denominator) return null;
|
||||
const total = Number(denominator.value);
|
||||
if (!Number.isFinite(total) || total <= 0) return null;
|
||||
const percent = (Number(numerator.value) / total) * 100;
|
||||
if (!Number.isFinite(percent)) return null;
|
||||
const rounded = new Intl.NumberFormat("ru-RU", {
|
||||
maximumFractionDigits: 1,
|
||||
}).format(percent);
|
||||
return `${rounded} %`;
|
||||
}
|
||||
|
||||
export function formatSnapshotTime(value: string): string {
|
||||
return new Intl.DateTimeFormat("ru-RU", {
|
||||
dateStyle: "medium",
|
||||
|
||||
Reference in New Issue
Block a user