diff --git a/apps/frontend/src/pages/broker-analytics/index.ts b/apps/frontend/src/pages/broker-analytics/index.ts new file mode 100644 index 0000000..0872b61 --- /dev/null +++ b/apps/frontend/src/pages/broker-analytics/index.ts @@ -0,0 +1 @@ +export { BrokerAnalyticsPage } from './ui/BrokerAnalyticsPage' diff --git a/apps/frontend/src/pages/broker-analytics/ui/BrokerAnalyticsPage.tsx b/apps/frontend/src/pages/broker-analytics/ui/BrokerAnalyticsPage.tsx new file mode 100644 index 0000000..0350ef3 --- /dev/null +++ b/apps/frontend/src/pages/broker-analytics/ui/BrokerAnalyticsPage.tsx @@ -0,0 +1,162 @@ +import { useBrokerAnalytics } from '@/entities/broker-analytics' +import { useBrokerAccountContext } from '@/widgets/broker-account-layout' + +function formatAmount(value: number, currency: string): string { + return `${value.toLocaleString('ru-RU', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${currency}` +} + +export function BrokerAnalyticsPage() { + const { accountId } = useBrokerAccountContext() + const { data, isLoading, isError } = useBrokerAnalytics(accountId) + + if (isLoading) { + return ( +
+
Загрузка...
+
+ ) + } + + if (isError) { + return ( +
+
+ Не удалось загрузить аналитику +
+
+ ) + } + + if (!data || (data.totalDeposits === 0 && data.totalReceived === 0)) { + return ( +
+
+ Нет данных для аналитики +
+
+ ) + } + + return ( +
+
+ {/* Вложено */} +
+

Вложено

+
+ + + + +
+
+ + {/* Получено */} +
+

Получено

+
+ + + + +
+
+
+ + {/* Сводка */} +
+

Сводка

+
+ + + {data.totalReturnPercent !== null && ( + + )} +
+
+
+ ) +} + +function Row({ + label, + value, + bold, + negative, +}: { + label: string + value: string + bold?: boolean + negative?: boolean +}) { + const color = negative ? 'var(--color-text-negative, #ef4444)' : 'var(--color-text-primary)' + return ( +
+ {label} + {value} +
+ ) +} + +function Divider() { + return ( +
+ ) +} + +function SummaryItem({ label, value }: { label: string; value: string }) { + return ( +
+
+ {label} +
+
+ {value} +
+
+ ) +}