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,39 +15,28 @@ 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
32- //TODO: throttling
33- private handleGoogleDocUrlChange = async ( value : string ) => {
34- const titles = value === ""
35- ? undefined
36- : await apiSingleton . statisticsApi . apiStatisticsGetSheetTitlesPost ( { url : value } )
37- this . setState ( { googleDocUrl : value , sheetTitles : titles } ) ;
38- }
39-
4028 public render ( ) {
4129 const homeworks = this . props . homeworks . filter ( h => h . tasks && h . tasks . length > 0 )
42- const { searched, googleDocUrl , sheetTitles } = this . state
30+ const { searched} = this . state
4331 const solutions = searched
4432 ? this . props . solutions . filter ( cm => ( cm . surname + " " + cm . name ) . toLowerCase ( ) . includes ( searched . toLowerCase ( ) ) )
4533 : this . props . solutions
4634
4735 return (
4836 < div >
4937 { searched &&
50- < Alert style = { { marginBottom : 5 } } severity = "info" > < b > Студенты:</ b > { searched . replaceAll ( " " , "·" ) }
38+ < Alert style = { { marginBottom : 5 } }
39+ severity = "info" > < b > Студенты:</ b > { searched . replaceAll ( " " , "·" ) }
5140 </ Alert > }
5241 < TableContainer >
5342 < Table stickyHeader aria-label = "sticky table" >
@@ -107,48 +96,11 @@ class StudentStats extends React.Component<IStudentStatsProps, IStudentStatsStat
10796 </ TableBody >
10897 </ Table >
10998 </ TableContainer >
110- < Grid container spacing = { 1 } style = { { marginTop : 15 } } >
111- < Grid item >
112- < Alert severity = "info" variant = { "standard" } >
113- Для загрузки таблицы необходимо разрешить доступ на редактирование по ссылке для Google Docs
114- страницы
115- </ Alert >
116- </ Grid >
117- < Grid container item spacing = { 1 } alignItems = { "center" } >
118- < Grid item >
119- < TextField size = { "small" } fullWidth label = { "Ссылка на Google Docs" } value = { googleDocUrl }
120- onChange = { event => {
121- event . persist ( )
122- this . handleGoogleDocUrlChange ( event . target . value )
123- } } />
124- </ Grid >
125- { sheetTitles && ! sheetTitles . succeeded && < Grid item >
126- < Alert severity = "error" >
127- { sheetTitles ! . errors ! [ 0 ] }
128- </ Alert >
129- </ Grid > }
130- { sheetTitles && sheetTitles . value && sheetTitles . value . length > 0 && < Grid item >
131- < Select
132- size = { "small" }
133- id = "demo-simple-select"
134- label = "Sheet"
135- value = { 0 }
136- >
137- { sheetTitles . value . map ( ( title , i ) => < MenuItem value = { i } > { title } </ MenuItem > ) }
138- </ Select >
139- </ Grid > }
140- { sheetTitles && sheetTitles . succeeded && < Grid item >
141- < Button fullWidth
142- variant = "text"
143- color = "primary"
144- type = "button" >
145- Загрузить
146- </ Button >
147- </ Grid > }
148- </ Grid >
149- </ Grid >
99+ < div style = { { marginTop : 15 } } >
100+ < LoadStatsToGoogleDoc />
101+ </ div >
150102 </ div >
151- ) ;
103+ )
152104 }
153105}
154106
0 commit comments