Merge pull request 'финансовый формат для ячеек' (#61) from fix-front into test

Reviewed-on: #61
This commit is contained in:
PotapovaA 2026-06-22 13:47:13 +03:00
commit 2df64fb020

View File

@ -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 (
<div
className="cell"
@ -87,4 +106,4 @@ const Cell = React.memo(({ cell, row, column, onClick, globalFilter, backgroundC
);
});
export default Cell;
export default Cell;