summaryrefslogtreecommitdiff
path: root/src/services/transforms.ts
blob: c12568ea8c4f8dd1966af661e574c2f0fed2ccc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import _ from 'lodash';
import { Field } from '../components/ListTable';

type Transformer = Field['transform'];

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: 'Приход',
  out: 'Расход',
});

export const transformStatus = transformer({
  waiting: 'Ожидание',
  executed: 'Проведена',
  cancelled: 'Отменена',
});