1
1
import React , { useEffect , useState } from "react" ;
2
2
import { CourseViewModel , HomeworkViewModel , StatisticsCourseMatesModel } from "@/api" ;
3
3
import { useNavigate , useParams } from 'react-router-dom' ;
4
- import { Table , TableBody , TableCell , TableContainer , TableHead , TableRow } from "@material-ui/core" ;
4
+ import { LinearProgress , Table , TableBody , TableCell , TableContainer , TableHead , TableRow } from "@material-ui/core" ;
5
5
import StudentStatsCell from "../Tasks/StudentStatsCell" ;
6
6
import { Alert , Button , Chip , Typography } from "@mui/material" ;
7
7
import { grey } from "@material-ui/core/colors" ;
@@ -15,7 +15,7 @@ interface IStudentStatsProps {
15
15
homeworks : HomeworkViewModel [ ] ;
16
16
isMentor : boolean ;
17
17
userId : string ;
18
- solutions : StatisticsCourseMatesModel [ ] ;
18
+ solutions : StatisticsCourseMatesModel [ ] | undefined ;
19
19
}
20
20
21
21
interface IStudentStatsState {
@@ -55,7 +55,7 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
55
55
56
56
const homeworks = props . homeworks . filter ( h => h . tasks && h . tasks . length > 0 )
57
57
const solutions = searched
58
- ? props . solutions . filter ( cm => ( cm . surname + " " + cm . name ) . toLowerCase ( ) . includes ( searched . toLowerCase ( ) ) )
58
+ ? props . solutions ? .filter ( cm => ( cm . surname + " " + cm . name ) . toLowerCase ( ) . includes ( searched . toLowerCase ( ) ) )
59
59
: props . solutions
60
60
61
61
const borderStyle = `1px solid ${ greyBorder } `
@@ -100,7 +100,8 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
100
100
101
101
return (
102
102
< div >
103
- { solutions . length === 0 && < Alert severity = "info" >
103
+ { props . solutions === undefined && < LinearProgress /> }
104
+ { props . solutions && props . solutions . length === 0 && < Alert severity = "info" >
104
105
На курс пока ещё никто не записался
105
106
</ Alert > }
106
107
{ searched &&
@@ -146,7 +147,7 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
146
147
< TableRow >
147
148
< TableCell style = { { zIndex : 10 } }
148
149
component = "td" >
149
- { solutions . length > 0 &&
150
+ { solutions && solutions . length > 0 &&
150
151
< Button startIcon = { < ShowChartIcon /> } color = "primary"
151
152
style = { { backgroundColor : 'transparent' } } size = 'medium'
152
153
onClick = { handleClick } >
@@ -190,7 +191,7 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
190
191
</ TableRow >
191
192
</ TableHead >
192
193
< TableBody >
193
- { solutions . map ( ( cm , index ) => {
194
+ { solutions && solutions . map ( ( cm , index ) => {
194
195
const homeworksSum = notTests
195
196
. flatMap ( homework =>
196
197
solutions
0 commit comments