diff --git a/src/pages/Analytics/Statistics.jsx b/src/pages/Analytics/Statistics.jsx index f52a77e..764e7ee 100644 --- a/src/pages/Analytics/Statistics.jsx +++ b/src/pages/Analytics/Statistics.jsx @@ -4,7 +4,7 @@ import { Fragment, memo, useCallback, useEffect, useState } from 'react' import LoaderPortal from '@components/LoaderPortal' import { WellSelector } from '@components/WellSelector' import { invokeWebApiWrapperAsync } from '@components/factory' -import { makeGroupColumn, makeNumericColumn, makeNumericRender, makeTextColumn, Table } from '@components/Table' +import { makeColumn, makeGroupColumn, makeNumericColumn, makeNumericRender, makeTextColumn, Table } from '@components/Table' import { OperationStatService, WellOperationService } from '@api' import { arrayOrDefault } from '@utils' @@ -18,10 +18,17 @@ const { Cell, Row } = Summary const numericRender = makeNumericRender() const speedNumericRender = (section) => numericRender(section?.speed) +const makeSectionSorter = (key, name) => (a, b) => (a?.[key]?.[name] ?? 0) - (b?.[key]?.[name] ?? 0) export const makeSectionColumn = (title, key, { speedRender } = {}) => makeGroupColumn(title, [ - makeNumericColumn('Проходка', key, null, null, (section => numericRender(section?.depth)), 100), - makeNumericColumn('Время', key, null, null, (section => numericRender(section?.time)), 100), - makeNumericColumn((<>Vрейсовая), key, null, null, speedRender ?? speedNumericRender, 100), + makeNumericColumn('Проходка', key, null, null, (section => numericRender(section?.depth)), 100, { + sorter: makeSectionSorter(key, 'depth'), + }), + makeNumericColumn('Время', key, null, null, (section => numericRender(section?.time)), 100, { + sorter: makeSectionSorter(key, 'time'), + }), + makeNumericColumn((<>Vрейсовая), key, null, null, speedRender ?? speedNumericRender, 100, { + sorter: makeSectionSorter(key, 'speed'), + }), ]) export const defaultColumns = [