Skip to content

Commit 4f9267a

Browse files
committed
Removed X-axis values, implemented X-axis description manually, implemented mockStats inDevelopment
1 parent 4c56f06 commit 4f9267a

File tree

1 file changed

+60
-14
lines changed
  • src/client/components/Courses/Course

1 file changed

+60
-14
lines changed

src/client/components/Courses/Course/Stats.tsx

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import React from 'react'
2-
import { Paper, Typography } from '@mui/material'
2+
import { Box, Paper, Typography } from '@mui/material'
33
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'
137
import { useCourseStatistics } from '../../../hooks/useCourse'
148

159
const Stats = ({ courseId }: { courseId: string }) => {
@@ -19,7 +13,48 @@ const Stats = ({ courseId }: { courseId: string }) => {
1913

2014
if (!stats || isLoading) return null
2115

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
2358

2459
usages.sort((a, b) => a.usageCount - b.usageCount)
2560

@@ -56,13 +91,24 @@ const Stats = ({ courseId }: { courseId: string }) => {
5691
>
5792
<Tooltip />
5893
<YAxis domain={[0, 100]} allowDataOverflow />
59-
<XAxis>
60-
<Label value={t('course:usageChartTitle')} position="bottom" />
61-
</XAxis>
94+
6295
<Bar dataKey="usageCount" fill="#8884d8" />
6396
</BarChart>
6497
</ResponsiveContainer>
6598
)}
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+
)}
66112
</Paper>
67113
)
68114
}

0 commit comments

Comments
 (0)