{typeLabel}
import { Link } from 'react-router-dom';
import { SkeletonBlock } from '@/shared/ui/SkeletonBlock';
import type { BrokerAccount, BrokerMoney, BrokerPortfolio } from '@/shared/api/responses';
import { buildBrokerAllocation } from '@/entities/broker-position';
import { BrokerAllocationBar } from '@/widgets/broker-allocation-chart';
function formatBrokerCurrencyValue(currency: string, value: number): string {
return new Intl.NumberFormat('ru-RU', {
style: 'currency',
currency: currency || 'RUB',
maximumFractionDigits: 2,
}).format(value);
}
function formatBrokerMoney(value: BrokerMoney | null | undefined): string {
if (!value) {
return '—';
}
return formatBrokerCurrencyValue(value.currency, value.value);
}
function formatBrokerSignedCurrencyValue(currency: string, value: number | null): string {
if (value === null) {
return '—';
}
const formatted = formatBrokerCurrencyValue(currency, Math.abs(value));
if (value > 0) {
return `+${formatted}`;
}
if (value < 0) {
return `−${formatted}`;
}
return formatted;
}
function formatBrokerSignedPercent(value: number | null): string {
if (value === null) {
return '—';
}
const formatted = `${new Intl.NumberFormat('ru-RU', {
maximumFractionDigits: 2,
}).format(Math.abs(value))}%`;
if (value > 0) {
return `+${formatted}`;
}
if (value < 0) {
return `−${formatted}`;
}
return formatted;
}
function formatBrokerDate(value: string | null | undefined): string | null {
if (!value) {
return null;
}
return new Date(value).toLocaleDateString('ru-RU');
}
function brokerAccountTypeLabel(type: 'brokerage' | 'iis'): string {
return type === 'iis' ? 'ИИС' : 'Брокерский счёт';
}
function BrokerAccountCardSkeleton({ name, typeLabel }: { name: string; typeLabel: string }) {
return (
{typeLabel} {brokerAccountTypeLabel(account.type)} Не удалось загрузить данные счёта{name}
{account.name}
{typeLabel}
Открыт {openedAt}
: null}