1
1
import React from 'react'
2
- import { Paper , Typography } from '@mui/material'
2
+ import { Box , Paper , Typography } from '@mui/material'
3
3
import { useTranslation } from 'react-i18next'
4
- import {
5
- BarChart ,
6
- Bar ,
7
- YAxis ,
8
- Tooltip ,
9
- XAxis ,
10
- Label ,
11
- ResponsiveContainer ,
12
- } from 'recharts'
4
+ import { BarChart , Bar , YAxis , Tooltip , ResponsiveContainer } from 'recharts'
5
+
6
+ import { inDevelopment } from '../../../../config'
13
7
import { useCourseStatistics } from '../../../hooks/useCourse'
14
8
15
9
const Stats = ( { courseId } : { courseId : string } ) => {
@@ -19,7 +13,48 @@ const Stats = ({ courseId }: { courseId: string }) => {
19
13
20
14
if ( ! stats || isLoading ) return null
21
15
22
- const { average, usagePercentage, usages } = stats
16
+ let statsUsed = stats
17
+
18
+ if ( inDevelopment ) {
19
+ statsUsed = {
20
+ average : 75 ,
21
+ usagePercentage : 0.85 ,
22
+ usages : [
23
+ {
24
+ id : 'module-1' ,
25
+ usageCount : 60 ,
26
+ userId : 'user-1' ,
27
+ chatInstanceId : 'chat-1' ,
28
+ } ,
29
+ {
30
+ id : 'module-2' ,
31
+ usageCount : 80 ,
32
+ userId : 'user-2' ,
33
+ chatInstanceId : 'chat-2' ,
34
+ } ,
35
+ {
36
+ id : 'module-3' ,
37
+ usageCount : 50 ,
38
+ userId : 'user-3' ,
39
+ chatInstanceId : 'chat-3' ,
40
+ } ,
41
+ {
42
+ id : 'module-4' ,
43
+ usageCount : 90 ,
44
+ userId : 'user-4' ,
45
+ chatInstanceId : 'chat-4' ,
46
+ } ,
47
+ {
48
+ id : 'module-5' ,
49
+ usageCount : 70 ,
50
+ userId : 'user-5' ,
51
+ chatInstanceId : 'chat-5' ,
52
+ } ,
53
+ ] ,
54
+ }
55
+ }
56
+
57
+ const { average, usagePercentage, usages } = statsUsed
23
58
24
59
usages . sort ( ( a , b ) => a . usageCount - b . usageCount )
25
60
@@ -56,13 +91,24 @@ const Stats = ({ courseId }: { courseId: string }) => {
56
91
>
57
92
< Tooltip />
58
93
< YAxis domain = { [ 0 , 100 ] } allowDataOverflow />
59
- < XAxis >
60
- < Label value = { t ( 'course:usageChartTitle' ) } position = "bottom" />
61
- </ XAxis >
94
+
62
95
< Bar dataKey = "usageCount" fill = "#8884d8" />
63
96
</ BarChart >
64
97
</ ResponsiveContainer >
65
98
) }
99
+ { usages && usages . length !== 0 && (
100
+ < Box textAlign = "center" ml = { 8 } mr = { 6 } >
101
+ < Box
102
+ sx = { {
103
+ width : '100%' ,
104
+ height : '1px' ,
105
+ backgroundColor : 'lightgray' ,
106
+ mb : 1 ,
107
+ } }
108
+ />
109
+ < Typography > { t ( 'course:usageChartTitle' ) } </ Typography >
110
+ </ Box >
111
+ ) }
66
112
</ Paper >
67
113
)
68
114
}
0 commit comments