/
FeatureMetricsStats.tsx
73 lines (69 loc) · 2.55 KB
/
FeatureMetricsStats.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
64
65
66
67
68
69
70
71
72
73
import { calculatePercentage } from 'utils/calculatePercentage';
import { useStyles } from './FeatureMetricsStats.styles';
import { Grid } from '@mui/material';
import { PrettifyLargeNumber } from 'component/common/PrettifyLargeNumber/PrettifyLargeNumber';
export interface IFeatureMetricsStatsProps {
totalYes: number;
totalNo: number;
hoursBack: number;
statsSectionId?: string;
tableSectionId?: string;
}
export const FeatureMetricsStats = ({
totalYes,
totalNo,
hoursBack,
statsSectionId,
tableSectionId,
}: IFeatureMetricsStatsProps) => {
const { classes: styles } = useStyles();
const hoursSuffix =
hoursBack === 1 ? 'in the last hour' : `in the last ${hoursBack} hours`;
return (
<Grid
container
spacing={2}
id={statsSectionId}
aria-describedby={tableSectionId}
aria-label="Feature metrics summary"
component="section"
>
<Grid item xs={12} sm={4}>
<article className={styles.item}>
<h3 className={styles.title}>Exposure</h3>
<p className={styles.value}>
<PrettifyLargeNumber value={totalYes} />
</p>
<p className={styles.text}>
Total exposure of the feature in the environment{' '}
{hoursSuffix}.
</p>
</article>
</Grid>
<Grid item xs={12} sm={4}>
<article className={styles.item}>
<h3 className={styles.title}>Exposure %</h3>
<p className={styles.value}>
{calculatePercentage(totalYes + totalNo, totalYes)}%
</p>
<p className={styles.text}>
% total exposure of the feature in the environment{' '}
{hoursSuffix}.
</p>
</article>
</Grid>
<Grid item xs={12} sm={4}>
<article className={styles.item}>
<h3 className={styles.title}>Requests</h3>
<p className={styles.value}>
<PrettifyLargeNumber value={totalYes + totalNo} />
</p>
<p className={styles.text}>
Total requests for the feature in the environment{' '}
{hoursSuffix}.
</p>
</article>
</Grid>
</Grid>
);
};