|
@@ -0,0 +1,48 @@
|
|
1
|
+import React from 'react';
|
|
2
|
+import { useTranslation } from 'react-i18next';
|
|
3
|
+import { useSelector } from 'react-redux';
|
|
4
|
+import { makeStyles } from 'tss-react/mui';
|
|
5
|
+
|
|
6
|
+import { IReduxState } from '../../../app/types';
|
|
7
|
+import { IconUsers } from '../../../base/icons/svg';
|
|
8
|
+import Label from '../../../base/label/components/web/Label';
|
|
9
|
+// eslint-disable-next-line lines-around-comment
|
|
10
|
+// @ts-ignore
|
|
11
|
+import { Tooltip } from '../../../base/tooltip';
|
|
12
|
+
|
|
13
|
+const useStyles = makeStyles()(theme => {
|
|
14
|
+ return {
|
|
15
|
+ label: {
|
|
16
|
+ backgroundColor: theme.palette.warning02,
|
|
17
|
+ color: theme.palette.uiBackground
|
|
18
|
+ }
|
|
19
|
+ };
|
|
20
|
+});
|
|
21
|
+
|
|
22
|
+const VisitorsCountLabel = () => {
|
|
23
|
+ const { classes: styles, theme } = useStyles();
|
|
24
|
+ const visitorsMode = useSelector((state: IReduxState) => state['features/visitors'].enabled);
|
|
25
|
+ const visitorsCount = useSelector((state: IReduxState) =>
|
|
26
|
+ state['features/visitors'].count || 0);
|
|
27
|
+ const { t } = useTranslation();
|
|
28
|
+
|
|
29
|
+ let visitorsCountLabel = String(visitorsCount);
|
|
30
|
+
|
|
31
|
+ // over 100 we show numbers lik 0.2 K or 9.5 K.
|
|
32
|
+ if (visitorsCount > 100) {
|
|
33
|
+ visitorsCountLabel = `${Math.round(visitorsCount / 100) / 10} K`;
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ return visitorsMode && (<Tooltip
|
|
37
|
+ content = { t('visitorsLabel', { count: visitorsCount }) }
|
|
38
|
+ position = { 'bottom' }>
|
|
39
|
+ <Label
|
|
40
|
+ className = { styles.label }
|
|
41
|
+ icon = { IconUsers }
|
|
42
|
+ iconColor = { theme.palette.icon04 }
|
|
43
|
+ id = 'visitorsCountLabel'
|
|
44
|
+ text = { `${visitorsCountLabel}` } />
|
|
45
|
+ </Tooltip>);
|
|
46
|
+};
|
|
47
|
+
|
|
48
|
+export default VisitorsCountLabel;
|