From e044b64de4b3851d815dceeaf2963ff8d6ba24c5 Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Sun, 21 Jun 2026 18:59:58 +0300 Subject: [PATCH] feat: migrate BrokerOperationsTable to design system --- .../ui/BrokerOperationsTable.tsx | 264 +++++++++--------- 1 file changed, 135 insertions(+), 129 deletions(-) diff --git a/apps/frontend/src/widgets/broker-operations-table/ui/BrokerOperationsTable.tsx b/apps/frontend/src/widgets/broker-operations-table/ui/BrokerOperationsTable.tsx index 06e0ef4..4854290 100644 --- a/apps/frontend/src/widgets/broker-operations-table/ui/BrokerOperationsTable.tsx +++ b/apps/frontend/src/widgets/broker-operations-table/ui/BrokerOperationsTable.tsx @@ -1,6 +1,8 @@ import { Link } from 'react-router-dom'; import type { ReactNode } from 'react'; import type { BrokerOperation, BrokerOperationsPage } from '@/shared/api/responses'; +import { Box } from '@mui/material'; +import { Button, Heading, Skeleton, Text } from '@moex-vibe/design-system'; import { TableSkeleton } from '@/shared/ui/TableSkeleton'; import { getBrokerOperationImpact, @@ -10,42 +12,33 @@ import { import { getBrokerInstrumentPath } from '@/entities/broker-position'; import { formatBrokerSignedMoney } from '@/shared/lib/formatters'; -const tableStyle = { +const tableSx = { width: '100%', borderCollapse: 'collapse', fontSize: 14, -} satisfies React.CSSProperties; +} as const; -const thStyle = { - borderBottom: '1px solid #e0e0e0', - color: 'var(--color-text-secondary)', +const thSx = { + borderBottom: '1px solid', + borderColor: 'divider', + color: 'text.secondary', fontWeight: 600, - padding: '10px 8px', -} satisfies React.CSSProperties; + p: 1, + textAlign: 'left', +} as const; -const tdStyle = { - borderBottom: '1px solid #eeeeee', - padding: '10px 8px', +const tdSx = { + borderBottom: '1px solid', + borderColor: 'divider', + p: 1, verticalAlign: 'top', -} satisfies React.CSSProperties; + textAlign: 'left', +} as const; -const pagButtonStyle = { - padding: '6px 14px', - borderRadius: 6, - border: '1px solid #e0e0e0', - background: 'var(--color-surface)', - color: 'var(--color-text)', - fontSize: 14, - fontWeight: 600, - cursor: 'pointer', - lineHeight: 1.4, -} satisfies React.CSSProperties; - -const pagButtonDisabledStyle = { - ...pagButtonStyle, - opacity: 0.35, - cursor: 'not-allowed', -} satisfies React.CSSProperties; +const tdSxRight = { + ...tdSx, + textAlign: 'right', +} as const; function formatDate(value: string | null) { if (!value) return '-'; @@ -53,11 +46,10 @@ function formatDate(value: string | null) { return new Date(value).toLocaleString('ru-RU'); } -function moneyColor(impact: BrokerOperationImpact): string { - if (impact === 'adds') return 'var(--color-positive)'; - if (impact === 'reduces') return 'var(--color-negative)'; - - return 'var(--color-text)'; +function operationTone(impact: BrokerOperationImpact) { + if (impact === 'adds') return 'positive' as const; + if (impact === 'reduces') return 'negative' as const; + return 'primary' as const; } function OperationInstrument({ operation }: { operation: BrokerOperation }) { @@ -69,19 +61,23 @@ function OperationInstrument({ operation }: { operation: BrokerOperation }) { }); const name = operation.name || operation.description; - if (!path && !name) return -; - if (!path) return {name}; + if (!path && !name) return -; + if (!path) return {name}; if (!ticker || ticker === '-') return {name}; return ( -
- - {ticker} + + + + {ticker} + {name && name !== ticker && ( - {name} + + {name} + )} -
+ ); } @@ -103,146 +99,156 @@ export function BrokerOperationsTable({ return (
-
-

{title}

+ {title} {headerAction} {pagination && ( -
- - : '←'} + + {pageNumber} - - -
+ {isFetching ? : '→'} + + )} -
+ {isLoading ? ( -
- - - - - - - - - + + + -
+ + + + + Дата - + + Тип - + + Инструмент - + + Сумма -
-
+ + ) : operations.length === 0 && !isFetching ? ( -

{emptyMessage}

+ + {emptyMessage} + ) : ( -
-
- - - - - - - - - - + + + + {operations.map((operation) => { const impact = getBrokerOperationImpact(operation); return ( - - - - - - + + ); })} - -
+ + + + + + Дата - + + Тип - + + Инструмент - + + Сумма -
{formatDate(operation.date)} - {getBrokerOperationTypeLabel(operation)} - + + + {formatDate(operation.date)} + + + {getBrokerOperationTypeLabel(operation)} + + - + {formatBrokerSignedMoney(operation.payment)} -
-
+ + + {isFetching && ( -
- + + )} -
+ )}
);