diff --git a/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx b/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx index 7212e7f..d3682b2 100644 --- a/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx +++ b/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx @@ -4,7 +4,6 @@ import styled from '@emotion/styled'; import { useRealtime } from '../../contexts/RealtimeContext'; import { toast } from 'react-toastify'; - const ContainerForText = styled.span` display: -webkit-box; -webkit-box-orient: vertical; @@ -43,9 +42,30 @@ const highlightText = (text, searchQuery) => { ); }; +// Функция для форматирования числа в финансовый формат +const formatNumber = (value) => { + if (value === null || value === undefined || value === '') return String(value || ''); + + const num = Number(value); + if (isNaN(num)) return String(value); + + // Форматируем число с 1 знаком после запятой и разделением по 3 цифры + return num.toLocaleString('ru-RU', { + minimumFractionDigits: 1, + maximumFractionDigits: 1, + useGrouping: true, + }); +}; + const Cell = React.memo(({ cell, row, column, onClick, globalFilter, backgroundColor, color, isEditable }) => { const cellValue = cell.getValue(); - const textValue = String(cellValue || ''); + let textValue = String(cellValue || ''); + + // Проверяем, является ли значение числом, и форматируем его + const isNumeric = !isNaN(Number(cellValue)) && cellValue !== null && cellValue !== undefined && cellValue !== ''; + if (isNumeric) { + textValue = formatNumber(cellValue); + } // Подсвечиваем текст с учетом поискового запроса const highlightedContent = useMemo(() => { @@ -58,7 +78,6 @@ const Cell = React.memo(({ cell, row, column, onClick, globalFilter, backgroundC cursor: 'not-allowed', } : {}; - return (