From 7c5af125086cfa6e3ca6c5b0f655b73252c3a1f8 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Thu, 17 Mar 2022 06:39:59 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D0=B0=D0=B1=D1=80=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BA=D0=B8=20=D0=B4=D0=B0=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/Columns/date.tsx | 25 +++++++++++++++++++++++++ src/components/Table/Columns/index.ts | 1 + src/components/Table/index.tsx | 1 + 3 files changed, 27 insertions(+) create mode 100644 src/components/Table/Columns/date.tsx diff --git a/src/components/Table/Columns/date.tsx b/src/components/Table/Columns/date.tsx new file mode 100644 index 0000000..c388cf6 --- /dev/null +++ b/src/components/Table/Columns/date.tsx @@ -0,0 +1,25 @@ +import { ReactNode } from 'react' + +import { formatDate } from '@utils' + +import makeColumn, { columnPropsOther } from '.' +import { DatePickerWrapper, makeDateSorter } from '..' + +export const makeDateColumn = ( + title: ReactNode, + key: string, + utc?: boolean, + format?: string, + other?: columnPropsOther +) => makeColumn(title, key, { + ...other, + render: (date) => ( +
+ {formatDate(date, utc, format) ?? '-'} +
+ ), + sorter: makeDateSorter(key), + input: , +}) + +export default makeDateColumn diff --git a/src/components/Table/Columns/index.ts b/src/components/Table/Columns/index.ts index fd0b327..babb1fd 100644 --- a/src/components/Table/Columns/index.ts +++ b/src/components/Table/Columns/index.ts @@ -2,6 +2,7 @@ import { ReactNode } from 'react' import { Rule } from 'antd/lib/form' import { ColumnProps } from 'antd/lib/table' +export { makeDateColumn } from './date' export { RegExpIsFloat, makeNumericRender, diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index 095c825..2e1fc8e 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -6,6 +6,7 @@ export { RegExpIsFloat, timezoneOptions, TimezoneSelect, + makeDateColumn, makeGroupColumn, makeColumn, makeColumnsPlanFact,