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,