-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstats.tsx
More file actions
64 lines (56 loc) · 1.81 KB
/
stats.tsx
File metadata and controls
64 lines (56 loc) · 1.81 KB
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
64
import * as React from 'react';
import { Row } from 'antd';
import * as moment from 'moment';
import Vega from 'src/pages/components/charts/vega';
import Async from 'src/pages/components/async';
import { connect } from 'react-redux';
import { State } from 'src/flux/reducers';
import { ClientState } from 'src/flux/reducers/client';
import * as ClientActions from 'src/flux/actions/client';
// tslint:disable-next-line:no-var-requires
const example = require('src/assets/chart_examples/area_graph.json');
// tslint:disable-next-line:no-var-requires
const humanize = require('humanize-plus');
interface StatsProps {
client?: ClientState;
endDate?: moment.Moment;
startDate?: moment.Moment;
fetchUsers?: () => void;
}
export class Stats extends React.Component<StatsProps, {}> {
public componentWillMount(): void {
this.props.fetchUsers();
}
public render(): JSX.Element {
const { startDate, endDate, client } = this.props;
return (
<div>
<Row style={{ textAlign: 'center', padding: '5em 0' }}>
<h1>Over the past {startDate.from(endDate, true)} there have been</h1>
<h2>
{humanize.intComma(543977)} chat messages across {humanize.intComma(client.users.size)}
active users in {humanize.intComma(45)} active rooms
</h2>
</Row>
<Row>
<Async url={example}>
<Vega />
</Async>
</Row>
</div>
);
}
}
const mapStateToProps = (state: State, props: StatsProps): StatsProps => {
return {
client: state.client,
endDate: state.dateRange.end,
startDate: state.dateRange.start,
};
};
const mapDispatchToProps = (dispatch): StatsProps => {
return {
fetchUsers: () => dispatch(ClientActions.getUsers()),
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Stats);