-
Notifications
You must be signed in to change notification settings - Fork 295
/
StakingEpochsDataTable.tsx
63 lines (58 loc) · 1.52 KB
/
StakingEpochsDataTable.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// @flow
import React, { Component } from 'react';
import type { Node } from 'react';
import { observer } from 'mobx-react';
import SVGInline from 'react-svg-inline';
import { map } from 'lodash';
import classNames from 'classnames';
import sortIcon from '../../../assets/images/ascending.inline.svg';
import styles from './StakingEpochs.scss';
type TableHeaders = {
name: string,
title: string,
};
type Props = {
tableHeaders: TableHeaders,
tableBody: Node,
order: string,
sortBy: string,
handleDataSort: Function,
};
@observer
export default class StakingEpochsDataTable extends Component<Props> {
render() {
const {
tableHeaders,
tableBody,
order,
sortBy,
handleDataSort,
} = this.props;
return (
<table>
<thead>
<tr>
{map(tableHeaders, (tableHeader) => {
const isSorted = tableHeader.name === sortBy;
const sortIconClasses = classNames([
styles.sortIcon,
isSorted ? styles.sorted : null,
isSorted && order === 'asc' ? styles.ascending : null,
]);
return (
<th
key={tableHeader.name}
onClick={() => handleDataSort(tableHeader.name)}
>
{tableHeader.title}
<SVGInline svg={sortIcon} className={sortIconClasses} />
</th>
);
})}
</tr>
</thead>
{tableBody}
</table>
);
}
}