11import React from "react" ;
2- import { CourseViewModel , HomeworkViewModel , ResultString , StatisticsCourseMatesModel } from "../../api/" ;
2+ import { CourseViewModel , HomeworkViewModel , StatisticsCourseMatesModel } from "../../api/" ;
33import { Table , TableBody , TableCell , TableContainer , TableHead , TableRow } from "@material-ui/core" ;
44import StudentStatsCell from "../Tasks/StudentStatsCell" ;
5- import { Alert , Button , Grid , MenuItem , Select , TextField } from "@mui/material" ;
6- import apiSingleton from "../../api/ApiSingleton " ;
5+ import { Alert , Grid } from "@mui/material" ;
6+ import LoadStatsToGoogleDoc from "components/Solutions/LoadStatsToGoogleDoc " ;
77
88interface IStudentStatsProps {
99 course : CourseViewModel ;
@@ -15,17 +15,13 @@ interface IStudentStatsProps {
1515
1616interface IStudentStatsState {
1717 searched : string
18- googleDocUrl : string
19- sheetTitles : ResultString | undefined
2018}
2119
2220class StudentStats extends React . Component < IStudentStatsProps , IStudentStatsState > {
2321 constructor ( props : IStudentStatsProps ) {
2422 super ( props ) ;
2523 this . state = {
26- searched : "" ,
27- googleDocUrl : "" ,
28- sheetTitles : undefined
24+ searched : ""
2925 }
3026
3127 // document.addEventListener('keydown', (event: KeyboardEvent) => {
@@ -45,17 +41,9 @@ class StudentStats extends React.Component<IStudentStatsProps, IStudentStatsStat
4541 // })
4642 }
4743
48- //TODO: throttling
49- private handleGoogleDocUrlChange = async ( value : string ) => {
50- const titles = value === ""
51- ? undefined
52- : await apiSingleton . statisticsApi . apiStatisticsGetSheetTitlesPost ( { url : value } )
53- this . setState ( { googleDocUrl : value , sheetTitles : titles } ) ;
54- }
55-
5644 public render ( ) {
5745 const homeworks = this . props . homeworks . filter ( h => h . tasks && h . tasks . length > 0 )
58- const { searched, googleDocUrl , sheetTitles } = this . state
46+ const { searched} = this . state
5947 const solutions = searched
6048 ? this . props . solutions . filter ( cm => ( cm . surname + " " + cm . name ) . toLowerCase ( ) . includes ( searched . toLowerCase ( ) ) )
6149 : this . props . solutions
@@ -69,7 +57,8 @@ class StudentStats extends React.Component<IStudentStatsProps, IStudentStatsStat
6957 return (
7058 < div >
7159 { searched &&
72- < Alert style = { { marginBottom : 5 } } severity = "info" > < b > Студенты:</ b > { searched . replaceAll ( " " , "·" ) }
60+ < Alert style = { { marginBottom : 5 } }
61+ severity = "info" > < b > Студенты:</ b > { searched . replaceAll ( " " , "·" ) }
7362 </ Alert > }
7463 < TableContainer style = { { maxHeight : 600 } } >
7564 < Table stickyHeader aria-label = "sticky table" >
@@ -133,48 +122,11 @@ class StudentStats extends React.Component<IStudentStatsProps, IStudentStatsStat
133122 </ TableBody >
134123 </ Table >
135124 </ TableContainer >
136- < Grid container spacing = { 1 } style = { { marginTop : 15 } } >
137- < Grid item >
138- < Alert severity = "info" variant = { "standard" } >
139- Для загрузки таблицы необходимо разрешить доступ на редактирование по ссылке для Google Docs
140- страницы
141- </ Alert >
142- </ Grid >
143- < Grid container item spacing = { 1 } alignItems = { "center" } >
144- < Grid item >
145- < TextField size = { "small" } fullWidth label = { "Ссылка на Google Docs" } value = { googleDocUrl }
146- onChange = { event => {
147- event . persist ( )
148- this . handleGoogleDocUrlChange ( event . target . value )
149- } } />
150- </ Grid >
151- { sheetTitles && ! sheetTitles . succeeded && < Grid item >
152- < Alert severity = "error" >
153- { sheetTitles ! . errors ! [ 0 ] }
154- </ Alert >
155- </ Grid > }
156- { sheetTitles && sheetTitles . value && sheetTitles . value . length > 0 && < Grid item >
157- < Select
158- size = { "small" }
159- id = "demo-simple-select"
160- label = "Sheet"
161- value = { 0 }
162- >
163- { sheetTitles . value . map ( ( title , i ) => < MenuItem value = { i } > { title } </ MenuItem > ) }
164- </ Select >
165- </ Grid > }
166- { sheetTitles && sheetTitles . succeeded && < Grid item >
167- < Button fullWidth
168- variant = "text"
169- color = "primary"
170- type = "button" >
171- Загрузить
172- </ Button >
173- </ Grid > }
174- </ Grid >
175- </ Grid >
125+ < div style = { { marginTop : 15 } } >
126+ < LoadStatsToGoogleDoc />
127+ </ div >
176128 </ div >
177- ) ;
129+ )
178130 }
179131}
180132
0 commit comments