import { SkeletonBlock } from '@/shared/ui/SkeletonBlock'; import type { BrokerAccountsAggregate } from '@/entities/broker-account'; import { buildBrokerAllocation } from '@/entities/broker-position'; import { BrokerAllocationBar } from '@/shared/ui/broker-allocation-bar'; import { formatBrokerCurrencyValue, formatBrokerSignedCurrencyValue, formatBrokerSignedPercent, } from '@/shared/lib/formatters'; export function BrokerAccountsSummary({ aggregate, availableCount, totalCount, isLoading, }: { aggregate: BrokerAccountsAggregate; availableCount: number; totalCount: number; isLoading: boolean; }) { if (isLoading) { return (
{[1, 2, 3].map((item) => (
))}
); } return (

Финансовый обзор

Счета в одном кадре

{totalCount} счетов {availableCount !== totalCount ? ( Доступно по {availableCount} из {totalCount} счетов ) : null}
{aggregate.portfolios.map((portfolioSummary) => { const allocation = buildBrokerAllocation({ account: { id: 'aggregate', type: 'brokerage', name: 'aggregate', status: 'ACCOUNT_STATUS_OPEN', openedAt: null, accessLevel: null, }, positionCounts: { shares: 0, bonds: 0, etf: 0, other: 0 }, totals: { shares: { currency: portfolioSummary.currency, units: '0', nano: 0, value: portfolioSummary.allocation.shares, }, bonds: { currency: portfolioSummary.currency, units: '0', nano: 0, value: portfolioSummary.allocation.bonds, }, etf: portfolioSummary.allocation.etf > 0 ? { currency: portfolioSummary.currency, units: '0', nano: 0, value: portfolioSummary.allocation.etf, } : null, currencies: { currency: portfolioSummary.currency, units: '0', nano: 0, value: portfolioSummary.allocation.cash, }, futures: null, options: null, structuredProducts: null, dfa: null, portfolio: { currency: portfolioSummary.currency, units: '0', nano: 0, value: portfolioSummary.total, }, }, yields: { expectedPercent: null, daily: null, dailyPercent: null }, cash: [], blockedCash: [], asOf: '', }); return (
{portfolioSummary.currency} {formatBrokerCurrencyValue(portfolioSummary.currency, portfolioSummary.total)}
За день
{formatBrokerSignedCurrencyValue( portfolioSummary.currency, portfolioSummary.daily, )}
Динамика
{formatBrokerSignedPercent(portfolioSummary.dailyPercent)}
Свободные деньги
{formatBrokerCurrencyValue( portfolioSummary.currency, aggregate.cash.find((cash) => cash.currency === portfolioSummary.currency) ?.value ?? 0, )}
); })}
); }