From d6c4261d26ae382c44398b5d72ed2be5e63fcbf1 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Mon, 14 Mar 2022 10:48:36 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=BE=20=D1=81=D1=82=D0=BE=D0=BB?= =?UTF-8?q?=D0=B1=D1=86=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Analytics/Statistics.jsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 = [