diff options
author | eug-vs <eug-vs@keemail.me> | 2021-04-17 15:21:08 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-04-17 15:21:08 +0300 |
commit | cfdce1fb1179cfe4f15fc26676f064ca10fb9ce4 (patch) | |
tree | a87cb7ed78dc2df79885b38c124cf061cdd351b5 | |
parent | f3a5275522c90a9ddc961b994a8c9adc041d0f3d (diff) | |
download | commercel-ui-cfdce1fb1179cfe4f15fc26676f064ca10fb9ce4.tar.gz |
refactor: move transformDate to transforms
-rw-r--r-- | src/services/account/index.ts | 3 | ||||
-rw-r--r-- | src/services/transfers/index.ts | 4 | ||||
-rw-r--r-- | src/services/transforms.ts | 3 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/services/account/index.ts b/src/services/account/index.ts index cbe56f5..ab8ab38 100644 --- a/src/services/account/index.ts +++ b/src/services/account/index.ts @@ -1,10 +1,11 @@ import { ServiceParams } from '../../lib/ServiceContext'; +import { transformDate } from '../transforms'; const service: ServiceParams = { route: 'account', name: 'Рассчётный счёт', tableFields: [ - { key: 'date', label: 'Дата', transform: date => new Date(date).toLocaleDateString() }, + { key: 'date', label: 'Дата', transform: transformDate }, { key: 'amount', label: 'Сумма' }, ], actions: [ diff --git a/src/services/transfers/index.ts b/src/services/transfers/index.ts index ece8dae..2a0cad1 100644 --- a/src/services/transfers/index.ts +++ b/src/services/transfers/index.ts @@ -1,6 +1,6 @@ import Form from './TransferForm'; import UploadPage from './TransfersUpload'; -import { transformOperation } from '../transforms'; +import { transformDate, transformOperation } from '../transforms'; import { ServiceParams } from '../../lib/ServiceContext'; import { Transfer } from '../types'; @@ -10,7 +10,7 @@ const service: ServiceParams<Transfer> = { name: 'Переводы', nameSingular: 'Перевод', tableFields: [ - { key: 'date', label: 'Дата', transform: date => new Date(date).toLocaleDateString() }, + { key: 'date', label: 'Дата', transform: transformDate }, { key: 'contractor.name', label: 'Контрагент' }, { key: 'operation', label: 'Операция', transform: transformOperation }, { key: 'amount', label: 'Сумма' }, diff --git a/src/services/transforms.ts b/src/services/transforms.ts index 2eea46f..c12568e 100644 --- a/src/services/transforms.ts +++ b/src/services/transforms.ts @@ -7,6 +7,9 @@ const transformer = (hash: Record<string, string | JSX.Element>): Transformer => return value => _.get(hash, value, value); }; +export const transformDate = (date: string): string => { + return new Date(date).toLocaleDateString(); +}; export const transformOperation = transformer({ in: 'Приход', |